/** | |
* ******************************************************************************* | |
* Copyright (c) 2008 Castor Technologies Inc. | |
* 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: | |
* Alain Picard (Castor Technologies Inc) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.omg.smm.impl; | |
import org.eclipse.emf.common.notify.Notification; | |
import org.eclipse.emf.common.notify.NotificationChain; | |
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.EcoreUtil; | |
import org.eclipse.gmt.modisco.omg.smm.Annotation; | |
import org.eclipse.gmt.modisco.omg.smm.SmmElement; | |
import org.eclipse.gmt.modisco.omg.smm.SmmPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Annotation</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.AnnotationImpl#getText <em>Text</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.AnnotationImpl#getOwner <em>Owner</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class AnnotationImpl extends SmmElementImpl implements Annotation { | |
/** | |
* The default value of the '{@link #getText() <em>Text</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getText() | |
* @generated | |
* @ordered | |
*/ | |
protected static final String TEXT_EDEFAULT = null; | |
/** | |
* The cached value of the '{@link #getText() <em>Text</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getText() | |
* @generated | |
* @ordered | |
*/ | |
protected String text = TEXT_EDEFAULT; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected AnnotationImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return SmmPackage.Literals.ANNOTATION; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String getText() { | |
return text; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setText(String newText) { | |
String oldText = text; | |
text = newText; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.ANNOTATION__TEXT, oldText, text)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public SmmElement getOwner() { | |
if (eContainerFeatureID != SmmPackage.ANNOTATION__OWNER) return null; | |
return (SmmElement)eContainer(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetOwner(SmmElement newOwner, NotificationChain msgs) { | |
msgs = eBasicSetContainer((InternalEObject)newOwner, SmmPackage.ANNOTATION__OWNER, msgs); | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setOwner(SmmElement newOwner) { | |
if (newOwner != eInternalContainer() || (eContainerFeatureID != SmmPackage.ANNOTATION__OWNER && newOwner != null)) { | |
if (EcoreUtil.isAncestor(this, newOwner)) | |
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ | |
NotificationChain msgs = null; | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
if (newOwner != null) | |
msgs = ((InternalEObject)newOwner).eInverseAdd(this, SmmPackage.SMM_ELEMENT__ANNOTATION, SmmElement.class, msgs); | |
msgs = basicSetOwner(newOwner, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.ANNOTATION__OWNER, newOwner, newOwner)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case SmmPackage.ANNOTATION__OWNER: | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
return basicSetOwner((SmmElement)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 SmmPackage.ANNOTATION__OWNER: | |
return basicSetOwner(null, msgs); | |
} | |
return super.eInverseRemove(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | |
switch (eContainerFeatureID) { | |
case SmmPackage.ANNOTATION__OWNER: | |
return eInternalContainer().eInverseRemove(this, SmmPackage.SMM_ELEMENT__ANNOTATION, SmmElement.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 SmmPackage.ANNOTATION__TEXT: | |
return getText(); | |
case SmmPackage.ANNOTATION__OWNER: | |
return getOwner(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case SmmPackage.ANNOTATION__TEXT: | |
setText((String)newValue); | |
return; | |
case SmmPackage.ANNOTATION__OWNER: | |
setOwner((SmmElement)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case SmmPackage.ANNOTATION__TEXT: | |
setText(TEXT_EDEFAULT); | |
return; | |
case SmmPackage.ANNOTATION__OWNER: | |
setOwner((SmmElement)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case SmmPackage.ANNOTATION__TEXT: | |
return TEXT_EDEFAULT == null ? text != null : !TEXT_EDEFAULT.equals(text); | |
case SmmPackage.ANNOTATION__OWNER: | |
return getOwner() != null; | |
} | |
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(" (text: "); //$NON-NLS-1$ | |
result.append(text); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //AnnotationImpl |