/** * <copyright> * </copyright> * * $Id$ */ package org.eclipse.buckminster.cspecxml.impl; import java.util.Collection; import org.eclipse.buckminster.cspecxml.IAttribute; import org.eclipse.buckminster.cspecxml.ICSpecXMLPackage; import org.eclipse.buckminster.cspecxml.IParameterType; import org.eclipse.buckminster.model.common.Documentation; 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; /** * <!-- begin-user-doc --> An implementation of the model object ' * <em><b>Attribute</b></em>'. <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li> * {@link org.eclipse.buckminster.cspecxml.impl.AttributeImpl#getDocumentation * <em>Documentation</em>}</li> * <li>{@link org.eclipse.buckminster.cspecxml.impl.AttributeImpl#getParameter * <em>Parameter</em>}</li> * <li>{@link org.eclipse.buckminster.cspecxml.impl.AttributeImpl#getName <em> * Name</em>}</li> * <li>{@link org.eclipse.buckminster.cspecxml.impl.AttributeImpl#getVersion * <em>Version</em>}</li> * </ul> * </p> * * @generated */ public class AttributeImpl extends EObjectImpl implements IAttribute { /** * The cached value of the '{@link #getDocumentation() * <em>Documentation</em>}' containment reference. <!-- begin-user-doc --> * <!-- end-user-doc --> * * @see #getDocumentation() * @generated * @ordered */ protected Documentation documentation; /** * The cached value of the '{@link #getParameter() <em>Parameter</em>}' * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc --> * * @see #getParameter() * @generated * @ordered */ protected EList<IParameterType> parameter; /** * 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 #getVersion() <em>Version</em>}' * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> * * @see #getVersion() * @generated * @ordered */ protected static final String VERSION_EDEFAULT = null; /** * The cached value of the '{@link #getVersion() <em>Version</em>}' * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> * * @see #getVersion() * @generated * @ordered */ protected String version = VERSION_EDEFAULT; /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ protected AttributeImpl() { super(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ public NotificationChain basicSetDocumentation(Documentation newDocumentation, NotificationChain msgs) { Documentation oldDocumentation = documentation; documentation = newDocumentation; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION, oldDocumentation, newDocumentation); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION: return getDocumentation(); case ICSpecXMLPackage.ATTRIBUTE__PARAMETER: return getParameter(); case ICSpecXMLPackage.ATTRIBUTE__NAME: return getName(); case ICSpecXMLPackage.ATTRIBUTE__VERSION: return getVersion(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION: return basicSetDocumentation(null, msgs); case ICSpecXMLPackage.ATTRIBUTE__PARAMETER: return ((InternalEList<?>) getParameter()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION: return documentation != null; case ICSpecXMLPackage.ATTRIBUTE__PARAMETER: return parameter != null && !parameter.isEmpty(); case ICSpecXMLPackage.ATTRIBUTE__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case ICSpecXMLPackage.ATTRIBUTE__VERSION: return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION: setDocumentation((Documentation) newValue); return; case ICSpecXMLPackage.ATTRIBUTE__PARAMETER: getParameter().clear(); getParameter().addAll((Collection<? extends IParameterType>) newValue); return; case ICSpecXMLPackage.ATTRIBUTE__NAME: setName((String) newValue); return; case ICSpecXMLPackage.ATTRIBUTE__VERSION: setVersion((String) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION: setDocumentation((Documentation) null); return; case ICSpecXMLPackage.ATTRIBUTE__PARAMETER: getParameter().clear(); return; case ICSpecXMLPackage.ATTRIBUTE__NAME: setName(NAME_EDEFAULT); return; case ICSpecXMLPackage.ATTRIBUTE__VERSION: setVersion(VERSION_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public Documentation getDocumentation() { return documentation; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public String getName() { return name; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public EList<IParameterType> getParameter() { if (parameter == null) { parameter = new EObjectContainmentEList<IParameterType>(IParameterType.class, this, ICSpecXMLPackage.ATTRIBUTE__PARAMETER); } return parameter; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public String getVersion() { return version; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void setDocumentation(Documentation newDocumentation) { if (newDocumentation != documentation) { NotificationChain msgs = null; if (documentation != null) msgs = ((InternalEObject) documentation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION, null, msgs); if (newDocumentation != null) msgs = ((InternalEObject) newDocumentation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION, null, msgs); msgs = basicSetDocumentation(newDocumentation, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ICSpecXMLPackage.ATTRIBUTE__DOCUMENTATION, newDocumentation, newDocumentation)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ICSpecXMLPackage.ATTRIBUTE__NAME, oldName, name)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void setVersion(String newVersion) { String oldVersion = version; version = newVersion; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ICSpecXMLPackage.ATTRIBUTE__VERSION, oldVersion, version)); } /** * <!-- 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(", version: "); result.append(version); result.append(')'); return result.toString(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override protected EClass eStaticClass() { return ICSpecXMLPackage.Literals.ATTRIBUTE; } } // AttributeImpl