/** * <copyright> * </copyright> * * $Id$ */ package org.eclipse.papyrus.customization.properties.generation.fieldselection.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.eclipse.papyrus.customization.properties.generation.fieldselection.ContextElement; import org.eclipse.papyrus.customization.properties.generation.fieldselection.FieldSelectionPackage; import org.eclipse.papyrus.customization.properties.generation.fieldselection.PropertyDefinition; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Context Element</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.papyrus.customization.properties.generation.fieldselection.impl.ContextElementImpl#getElements <em>Elements</em>}</li> * <li>{@link org.eclipse.papyrus.customization.properties.generation.fieldselection.impl.ContextElementImpl#getProperties <em>Properties</em>}</li> * <li>{@link org.eclipse.papyrus.customization.properties.generation.fieldselection.impl.ContextElementImpl#getName <em>Name</em>}</li> * </ul> * </p> * * @generated */ public class ContextElementImpl extends EObjectImpl implements ContextElement { /** * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getElements() * @generated * @ordered */ protected EList<ContextElement> elements; /** * The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getProperties() * @generated * @ordered */ protected EList<PropertyDefinition> properties; /** * 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; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ContextElementImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return FieldSelectionPackage.Literals.CONTEXT_ELEMENT; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<ContextElement> getElements() { if (elements == null) { elements = new EObjectContainmentEList<ContextElement>(ContextElement.class, this, FieldSelectionPackage.CONTEXT_ELEMENT__ELEMENTS); } return elements; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<PropertyDefinition> getProperties() { if (properties == null) { properties = new EObjectContainmentEList<PropertyDefinition>(PropertyDefinition.class, this, FieldSelectionPackage.CONTEXT_ELEMENT__PROPERTIES); } return properties; } /** * <!-- 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, FieldSelectionPackage.CONTEXT_ELEMENT__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case FieldSelectionPackage.CONTEXT_ELEMENT__ELEMENTS: return ((InternalEList<?>)getElements()).basicRemove(otherEnd, msgs); case FieldSelectionPackage.CONTEXT_ELEMENT__PROPERTIES: return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case FieldSelectionPackage.CONTEXT_ELEMENT__ELEMENTS: return getElements(); case FieldSelectionPackage.CONTEXT_ELEMENT__PROPERTIES: return getProperties(); case FieldSelectionPackage.CONTEXT_ELEMENT__NAME: return getName(); } 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 FieldSelectionPackage.CONTEXT_ELEMENT__ELEMENTS: getElements().clear(); getElements().addAll((Collection<? extends ContextElement>)newValue); return; case FieldSelectionPackage.CONTEXT_ELEMENT__PROPERTIES: getProperties().clear(); getProperties().addAll((Collection<? extends PropertyDefinition>)newValue); return; case FieldSelectionPackage.CONTEXT_ELEMENT__NAME: setName((String)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case FieldSelectionPackage.CONTEXT_ELEMENT__ELEMENTS: getElements().clear(); return; case FieldSelectionPackage.CONTEXT_ELEMENT__PROPERTIES: getProperties().clear(); return; case FieldSelectionPackage.CONTEXT_ELEMENT__NAME: setName(NAME_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case FieldSelectionPackage.CONTEXT_ELEMENT__ELEMENTS: return elements != null && !elements.isEmpty(); case FieldSelectionPackage.CONTEXT_ELEMENT__PROPERTIES: return properties != null && !properties.isEmpty(); case FieldSelectionPackage.CONTEXT_ELEMENT__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); } return super.eIsSet(featureID); } /** * <!-- 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(); } } //ContextElementImpl