/** */ package org.yakindu.base.types.impl; import java.util.Collection; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.yakindu.base.base.BasePackage; import org.yakindu.base.base.NamedElement; import org.yakindu.base.types.AnnotatableElement; import org.yakindu.base.types.Annotation; import org.yakindu.base.types.Declaration; import org.yakindu.base.types.PackageMember; import org.yakindu.base.types.Type; import org.yakindu.base.types.TypeSpecifier; import org.yakindu.base.types.TypesPackage; import org.yakindu.base.types.TypesUtil; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Declaration</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.yakindu.base.types.impl.DeclarationImpl#getType <em>Type</em>}</li> * <li>{@link org.yakindu.base.types.impl.DeclarationImpl#getTypeSpecifier <em>Type Specifier</em>}</li> * <li>{@link org.yakindu.base.types.impl.DeclarationImpl#getName <em>Name</em>}</li> * <li>{@link org.yakindu.base.types.impl.DeclarationImpl#getId <em>Id</em>}</li> * <li>{@link org.yakindu.base.types.impl.DeclarationImpl#getAnnotations <em>Annotations</em>}</li> * </ul> * * @generated */ public abstract class DeclarationImpl extends EObjectImpl implements Declaration { /** * The cached value of the '{@link #getTypeSpecifier() <em>Type Specifier</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTypeSpecifier() * @generated * @ordered */ protected TypeSpecifier typeSpecifier; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * The default value of the '{@link #getId() <em>Id</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getId() * @generated * @ordered */ protected static final String ID_EDEFAULT = null; /** * The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getAnnotations() * @generated * @ordered */ protected EList<Annotation> annotations; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected DeclarationImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return TypesPackage.Literals.DECLARATION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Type getType() { Type type = basicGetType(); return type != null && type.eIsProxy() ? (Type)eResolveProxy((InternalEObject)type) : type; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public Type basicGetType() { if (getTypeSpecifier() != null) { return getTypeSpecifier().getType(); } return null; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public TypeSpecifier getTypeSpecifier() { return typeSpecifier; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTypeSpecifier(TypeSpecifier newTypeSpecifier, NotificationChain msgs) { TypeSpecifier oldTypeSpecifier = typeSpecifier; typeSpecifier = newTypeSpecifier; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypesPackage.DECLARATION__TYPE_SPECIFIER, oldTypeSpecifier, newTypeSpecifier); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTypeSpecifier(TypeSpecifier newTypeSpecifier) { if (newTypeSpecifier != typeSpecifier) { NotificationChain msgs = null; if (typeSpecifier != null) msgs = ((InternalEObject)typeSpecifier).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TypesPackage.DECLARATION__TYPE_SPECIFIER, null, msgs); if (newTypeSpecifier != null) msgs = ((InternalEObject)newTypeSpecifier).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TypesPackage.DECLARATION__TYPE_SPECIFIER, null, msgs); msgs = basicSetTypeSpecifier(newTypeSpecifier, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.DECLARATION__TYPE_SPECIFIER, newTypeSpecifier, newTypeSpecifier)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.DECLARATION__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Annotation> getAnnotations() { if (annotations == null) { annotations = new EObjectContainmentEList<Annotation>(Annotation.class, this, TypesPackage.DECLARATION__ANNOTATIONS); } return annotations; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ public Annotation getAnnotationOfType(final String typeName) { EList<Annotation> annotations = getAnnotations(); for (Annotation annotation : annotations) { if (typeName.equals(annotation.getType().getName())) { return annotation; } } return null; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case TypesPackage.DECLARATION__TYPE: if (resolve) return getType(); return basicGetType(); case TypesPackage.DECLARATION__TYPE_SPECIFIER: return getTypeSpecifier(); case TypesPackage.DECLARATION__NAME: return getName(); case TypesPackage.DECLARATION__ID: return getId(); case TypesPackage.DECLARATION__ANNOTATIONS: return getAnnotations(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case TypesPackage.DECLARATION__TYPE_SPECIFIER: setTypeSpecifier((TypeSpecifier)newValue); return; case TypesPackage.DECLARATION__NAME: setName((String)newValue); return; case TypesPackage.DECLARATION__ANNOTATIONS: getAnnotations().clear(); getAnnotations().addAll((Collection<? extends Annotation>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case TypesPackage.DECLARATION__TYPE_SPECIFIER: setTypeSpecifier((TypeSpecifier)null); return; case TypesPackage.DECLARATION__NAME: setName(NAME_EDEFAULT); return; case TypesPackage.DECLARATION__ANNOTATIONS: getAnnotations().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case TypesPackage.DECLARATION__TYPE: return basicGetType() != null; case TypesPackage.DECLARATION__TYPE_SPECIFIER: return typeSpecifier != null; case TypesPackage.DECLARATION__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case TypesPackage.DECLARATION__ID: return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId()); case TypesPackage.DECLARATION__ANNOTATIONS: return annotations != null && !annotations.isEmpty(); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { if (baseClass == NamedElement.class) { switch (derivedFeatureID) { case TypesPackage.DECLARATION__NAME: return BasePackage.NAMED_ELEMENT__NAME; default: return -1; } } if (baseClass == AnnotatableElement.class) { switch (derivedFeatureID) { default: return -1; } } if (baseClass == PackageMember.class) { switch (derivedFeatureID) { case TypesPackage.DECLARATION__ID: return TypesPackage.PACKAGE_MEMBER__ID; case TypesPackage.DECLARATION__ANNOTATIONS: return TypesPackage.PACKAGE_MEMBER__ANNOTATIONS; default: return -1; } } return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { if (baseClass == NamedElement.class) { switch (baseFeatureID) { case BasePackage.NAMED_ELEMENT__NAME: return TypesPackage.DECLARATION__NAME; default: return -1; } } if (baseClass == AnnotatableElement.class) { switch (baseFeatureID) { default: return -1; } } if (baseClass == PackageMember.class) { switch (baseFeatureID) { case TypesPackage.PACKAGE_MEMBER__ID: return TypesPackage.DECLARATION__ID; case TypesPackage.PACKAGE_MEMBER__ANNOTATIONS: return TypesPackage.DECLARATION__ANNOTATIONS; default: return -1; } } return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (name: "); result.append(name); result.append(')'); return result.toString(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ @Override public String getId() { return TypesUtil.computeQID(this); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case TypesPackage.DECLARATION__TYPE_SPECIFIER: return basicSetTypeSpecifier(null, msgs); case TypesPackage.DECLARATION__ANNOTATIONS: return ((InternalEList<?>)getAnnotations()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } } //DeclarationImpl