| /** |
| * Copyright (c) 2011-2012 Eclipse contributors and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| */ |
| package org.eclipse.emf.ecore.xcore.impl; |
| |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.emf.ecore.xcore.XEnum; |
| import org.eclipse.emf.ecore.xcore.XEnumLiteral; |
| import org.eclipse.emf.ecore.xcore.XcorePackage; |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>XEnum Literal</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XEnumLiteralImpl#getValue <em>Value</em>}</li> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XEnumLiteralImpl#getLiteral <em>Literal</em>}</li> |
| * <li>{@link org.eclipse.emf.ecore.xcore.impl.XEnumLiteralImpl#getEnum <em>Enum</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class XEnumLiteralImpl extends XNamedElementImpl implements XEnumLiteral |
| { |
| /** |
| * The default value of the '{@link #getValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected static final int VALUE_EDEFAULT = 0; |
| |
| /** |
| * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected int value = VALUE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getLiteral() <em>Literal</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLiteral() |
| * @generated |
| * @ordered |
| */ |
| protected static final String LITERAL_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getLiteral() <em>Literal</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLiteral() |
| * @generated |
| * @ordered |
| */ |
| protected String literal = LITERAL_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected XEnumLiteralImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return XcorePackage.Literals.XENUM_LITERAL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public int getValue() |
| { |
| return value; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setValue(int newValue) |
| { |
| int oldValue = value; |
| value = newValue; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, XcorePackage.XENUM_LITERAL__VALUE, oldValue, value)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getLiteral() |
| { |
| return literal; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setLiteral(String newLiteral) |
| { |
| String oldLiteral = literal; |
| literal = newLiteral; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, XcorePackage.XENUM_LITERAL__LITERAL, oldLiteral, literal)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public XEnum getEnum() |
| { |
| if (eContainerFeatureID() != XcorePackage.XENUM_LITERAL__ENUM) return null; |
| return (XEnum)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XENUM_LITERAL__ENUM: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return eBasicSetContainer(otherEnd, XcorePackage.XENUM_LITERAL__ENUM, msgs); |
| } |
| return super.eInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XENUM_LITERAL__ENUM: |
| return eBasicSetContainer(null, XcorePackage.XENUM_LITERAL__ENUM, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) |
| { |
| switch (eContainerFeatureID()) |
| { |
| case XcorePackage.XENUM_LITERAL__ENUM: |
| return eInternalContainer().eInverseRemove(this, XcorePackage.XENUM__LITERALS, XEnum.class, msgs); |
| } |
| return super.eBasicRemoveFromContainerFeature(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XENUM_LITERAL__VALUE: |
| return getValue(); |
| case XcorePackage.XENUM_LITERAL__LITERAL: |
| return getLiteral(); |
| case XcorePackage.XENUM_LITERAL__ENUM: |
| return getEnum(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XENUM_LITERAL__VALUE: |
| setValue((Integer)newValue); |
| return; |
| case XcorePackage.XENUM_LITERAL__LITERAL: |
| setLiteral((String)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XENUM_LITERAL__VALUE: |
| setValue(VALUE_EDEFAULT); |
| return; |
| case XcorePackage.XENUM_LITERAL__LITERAL: |
| setLiteral(LITERAL_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case XcorePackage.XENUM_LITERAL__VALUE: |
| return value != VALUE_EDEFAULT; |
| case XcorePackage.XENUM_LITERAL__LITERAL: |
| return LITERAL_EDEFAULT == null ? literal != null : !LITERAL_EDEFAULT.equals(literal); |
| case XcorePackage.XENUM_LITERAL__ENUM: |
| return getEnum() != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() |
| { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (value: "); |
| result.append(value); |
| result.append(", literal: "); |
| result.append(literal); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //XEnumLiteralImpl |