/******************************************************************************* * Copyright (c) 2010, 2015 Willink Transformations and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * E.D.Willink - initial API and implementation *******************************************************************************/ package org.eclipse.ocl.xtext.basecs.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.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.ocl.xtext.basecs.BaseCSPackage; import org.eclipse.ocl.xtext.basecs.SpecificationCS; import org.eclipse.ocl.xtext.basecs.StructuralFeatureCS; import org.eclipse.ocl.xtext.basecs.StructuredClassCS; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Structural Feature CS</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.eclipse.ocl.xtext.basecs.impl.StructuralFeatureCSImpl#getDefault <em>Default</em>}</li> * <li>{@link org.eclipse.ocl.xtext.basecs.impl.StructuralFeatureCSImpl#getOwnedDefaultExpressions <em>Owned Default Expressions</em>}</li> * <li>{@link org.eclipse.ocl.xtext.basecs.impl.StructuralFeatureCSImpl#getOwningClass <em>Owning Class</em>}</li> * </ul> * * @generated */ public abstract class StructuralFeatureCSImpl extends FeatureCSImpl implements StructuralFeatureCS { /** * The default value of the '{@link #getDefault() <em>Default</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDefault() * @generated * @ordered */ protected static final String DEFAULT_EDEFAULT = null; /** * The cached value of the '{@link #getDefault() <em>Default</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDefault() * @generated * @ordered */ protected String default_ = DEFAULT_EDEFAULT; /** * The cached value of the '{@link #getOwnedDefaultExpressions() <em>Owned Default Expressions</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOwnedDefaultExpressions() * @generated * @ordered */ protected EList<SpecificationCS> ownedDefaultExpressions; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected StructuralFeatureCSImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return BaseCSPackage.Literals.STRUCTURAL_FEATURE_CS; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public StructuredClassCS getOwningClass() { if (eContainerFeatureID() != BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS) return null; return (StructuredClassCS)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetOwningClass(StructuredClassCS newOwningClass, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newOwningClass, BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setOwningClass(StructuredClassCS newOwningClass) { if (newOwningClass != eInternalContainer() || (eContainerFeatureID() != BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS && newOwningClass != null)) { if (EcoreUtil.isAncestor(this, newOwningClass)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newOwningClass != null) msgs = ((InternalEObject)newOwningClass).eInverseAdd(this, BaseCSPackage.STRUCTURED_CLASS_CS__OWNED_PROPERTIES, StructuredClassCS.class, msgs); msgs = basicSetOwningClass(newOwningClass, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS, newOwningClass, newOwningClass)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String getDefault() { return default_; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setDefault(String newDefault) { String oldDefault = default_; default_ = newDefault; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, BaseCSPackage.STRUCTURAL_FEATURE_CS__DEFAULT, oldDefault, default_)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public EList<SpecificationCS> getOwnedDefaultExpressions() { if (ownedDefaultExpressions == null) { ownedDefaultExpressions = new EObjectContainmentEList<SpecificationCS>(SpecificationCS.class, this, BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNED_DEFAULT_EXPRESSIONS); } return ownedDefaultExpressions; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { return super.toString(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetOwningClass((StructuredClassCS)otherEnd, 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 BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNED_DEFAULT_EXPRESSIONS: return ((InternalEList<?>)getOwnedDefaultExpressions()).basicRemove(otherEnd, msgs); case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: return basicSetOwningClass(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: return eInternalContainer().eInverseRemove(this, BaseCSPackage.STRUCTURED_CLASS_CS__OWNED_PROPERTIES, StructuredClassCS.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 BaseCSPackage.STRUCTURAL_FEATURE_CS__DEFAULT: return getDefault(); case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNED_DEFAULT_EXPRESSIONS: return getOwnedDefaultExpressions(); case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: return getOwningClass(); } 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 BaseCSPackage.STRUCTURAL_FEATURE_CS__DEFAULT: setDefault((String)newValue); return; case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNED_DEFAULT_EXPRESSIONS: getOwnedDefaultExpressions().clear(); getOwnedDefaultExpressions().addAll((Collection<? extends SpecificationCS>)newValue); return; case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: setOwningClass((StructuredClassCS)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case BaseCSPackage.STRUCTURAL_FEATURE_CS__DEFAULT: setDefault(DEFAULT_EDEFAULT); return; case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNED_DEFAULT_EXPRESSIONS: getOwnedDefaultExpressions().clear(); return; case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: setOwningClass((StructuredClassCS)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case BaseCSPackage.STRUCTURAL_FEATURE_CS__DEFAULT: return DEFAULT_EDEFAULT == null ? default_ != null : !DEFAULT_EDEFAULT.equals(default_); case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNED_DEFAULT_EXPRESSIONS: return ownedDefaultExpressions != null && !ownedDefaultExpressions.isEmpty(); case BaseCSPackage.STRUCTURAL_FEATURE_CS__OWNING_CLASS: return getOwningClass() != null; } return super.eIsSet(featureID); } } //StructuralFeatureCSImpl