/**
* <copyright>
* </copyright>
*
* $Id$
*/
package orgomg.cwm.objectmodel.core.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 orgomg.cwm.objectmodel.core.CorePackage;
import orgomg.cwm.objectmodel.core.Multiplicity;
import orgomg.cwm.objectmodel.core.MultiplicityRange;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Multiplicity Range</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link orgomg.cwm.objectmodel.core.impl.MultiplicityRangeImpl#getLower <em>Lower</em>}</li>
* <li>{@link orgomg.cwm.objectmodel.core.impl.MultiplicityRangeImpl#getUpper <em>Upper</em>}</li>
* <li>{@link orgomg.cwm.objectmodel.core.impl.MultiplicityRangeImpl#getMultiplicity <em>Multiplicity</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MultiplicityRangeImpl extends ElementImpl implements MultiplicityRange {
/**
* The default value of the '{@link #getLower() <em>Lower</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLower()
* @generated
* @ordered
*/
protected static final long LOWER_EDEFAULT = 0L;
/**
* The cached value of the '{@link #getLower() <em>Lower</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLower()
* @generated
* @ordered
*/
protected long lower = LOWER_EDEFAULT;
/**
* The default value of the '{@link #getUpper() <em>Upper</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUpper()
* @generated
* @ordered
*/
protected static final long UPPER_EDEFAULT = 0L;
/**
* The cached value of the '{@link #getUpper() <em>Upper</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUpper()
* @generated
* @ordered
*/
protected long upper = UPPER_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MultiplicityRangeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CorePackage.Literals.MULTIPLICITY_RANGE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public long getLower() {
return lower;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setLower(long newLower) {
long oldLower = lower;
lower = newLower;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.MULTIPLICITY_RANGE__LOWER, oldLower, lower));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public long getUpper() {
return upper;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setUpper(long newUpper) {
long oldUpper = upper;
upper = newUpper;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.MULTIPLICITY_RANGE__UPPER, oldUpper, upper));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Multiplicity getMultiplicity() {
if (eContainerFeatureID() != CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY) return null;
return (Multiplicity)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetMultiplicity(Multiplicity newMultiplicity, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newMultiplicity, CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMultiplicity(Multiplicity newMultiplicity) {
if (newMultiplicity != eInternalContainer() || (eContainerFeatureID() != CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY && newMultiplicity != null)) {
if (EcoreUtil.isAncestor(this, newMultiplicity))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newMultiplicity != null)
msgs = ((InternalEObject)newMultiplicity).eInverseAdd(this, CorePackage.MULTIPLICITY__RANGE, Multiplicity.class, msgs);
msgs = basicSetMultiplicity(newMultiplicity, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY, newMultiplicity, newMultiplicity));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetMultiplicity((Multiplicity)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 CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
return basicSetMultiplicity(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
return eInternalContainer().eInverseRemove(this, CorePackage.MULTIPLICITY__RANGE, Multiplicity.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 CorePackage.MULTIPLICITY_RANGE__LOWER:
return getLower();
case CorePackage.MULTIPLICITY_RANGE__UPPER:
return getUpper();
case CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
return getMultiplicity();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CorePackage.MULTIPLICITY_RANGE__LOWER:
setLower((Long)newValue);
return;
case CorePackage.MULTIPLICITY_RANGE__UPPER:
setUpper((Long)newValue);
return;
case CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
setMultiplicity((Multiplicity)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CorePackage.MULTIPLICITY_RANGE__LOWER:
setLower(LOWER_EDEFAULT);
return;
case CorePackage.MULTIPLICITY_RANGE__UPPER:
setUpper(UPPER_EDEFAULT);
return;
case CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
setMultiplicity((Multiplicity)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CorePackage.MULTIPLICITY_RANGE__LOWER:
return lower != LOWER_EDEFAULT;
case CorePackage.MULTIPLICITY_RANGE__UPPER:
return upper != UPPER_EDEFAULT;
case CorePackage.MULTIPLICITY_RANGE__MULTIPLICITY:
return getMultiplicity() != 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(" (lower: ");
result.append(lower);
result.append(", upper: ");
result.append(upper);
result.append(')');
return result.toString();
}
} //MultiplicityRangeImpl