/******************************************************************************* * Copyright (c) 2007, 2009 Borland Software Corporation 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: * Borland Software Corporation - initial API and implementation *******************************************************************************/ package simpleuml.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.EDataTypeUniqueEList; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import simpleuml.ModelElement; import simpleuml.SimpleumlPackage; import simpleuml.TaggedValue; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Model Element</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link simpleuml.impl.ModelElementImpl#getName <em>Name</em>}</li> * <li>{@link simpleuml.impl.ModelElementImpl#getStereotype <em>Stereotype</em>}</li> * <li>{@link simpleuml.impl.ModelElementImpl#getTaggedValue <em>Tagged Value</em>}</li> * </ul> * </p> * * @generated */ public abstract class ModelElementImpl extends EObjectImpl implements ModelElement { /** * 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 cached value of the '{@link #getStereotype() <em>Stereotype</em>}' attribute list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getStereotype() * @generated * @ordered */ protected EList<String> stereotype; /** * The cached value of the '{@link #getTaggedValue() <em>Tagged Value</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTaggedValue() * @generated * @ordered */ protected EList<TaggedValue> taggedValue; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ModelElementImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SimpleumlPackage.Literals.MODEL_ELEMENT; } /** * <!-- 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, SimpleumlPackage.MODEL_ELEMENT__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<String> getStereotype() { if (stereotype == null) { stereotype = new EDataTypeUniqueEList<String>(String.class, this, SimpleumlPackage.MODEL_ELEMENT__STEREOTYPE); } return stereotype; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<TaggedValue> getTaggedValue() { if (taggedValue == null) { taggedValue = new EObjectContainmentEList<TaggedValue>(TaggedValue.class, this, SimpleumlPackage.MODEL_ELEMENT__TAGGED_VALUE); } return taggedValue; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SimpleumlPackage.MODEL_ELEMENT__TAGGED_VALUE: return ((InternalEList<?>)getTaggedValue()).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 SimpleumlPackage.MODEL_ELEMENT__NAME: return getName(); case SimpleumlPackage.MODEL_ELEMENT__STEREOTYPE: return getStereotype(); case SimpleumlPackage.MODEL_ELEMENT__TAGGED_VALUE: return getTaggedValue(); } 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 SimpleumlPackage.MODEL_ELEMENT__NAME: setName((String)newValue); return; case SimpleumlPackage.MODEL_ELEMENT__STEREOTYPE: getStereotype().clear(); getStereotype().addAll((Collection<? extends String>)newValue); return; case SimpleumlPackage.MODEL_ELEMENT__TAGGED_VALUE: getTaggedValue().clear(); getTaggedValue().addAll((Collection<? extends TaggedValue>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case SimpleumlPackage.MODEL_ELEMENT__NAME: setName(NAME_EDEFAULT); return; case SimpleumlPackage.MODEL_ELEMENT__STEREOTYPE: getStereotype().clear(); return; case SimpleumlPackage.MODEL_ELEMENT__TAGGED_VALUE: getTaggedValue().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SimpleumlPackage.MODEL_ELEMENT__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case SimpleumlPackage.MODEL_ELEMENT__STEREOTYPE: return stereotype != null && !stereotype.isEmpty(); case SimpleumlPackage.MODEL_ELEMENT__TAGGED_VALUE: return taggedValue != null && !taggedValue.isEmpty(); } 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: "); //$NON-NLS-1$ result.append(name); result.append(", stereotype: "); //$NON-NLS-1$ result.append(stereotype); result.append(')'); return result.toString(); } } //ModelElementImpl