/** * <copyright> * </copyright> * * $Id$ */ package org.eclipse.gmf.mappings.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.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.gmf.mappings.GMFMapPackage; import org.eclipse.gmf.mappings.Measurable; import org.eclipse.gmf.mappings.MetricContainer; import org.eclipse.gmf.mappings.MetricRule; import org.eclipse.gmf.mappings.ValueExpression; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Metric Rule</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getName <em>Name</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getDescription <em>Description</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getKey <em>Key</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getRule <em>Rule</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getTarget <em>Target</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getLowLimit <em>Low Limit</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getHighLimit <em>High Limit</em>}</li> * <li>{@link org.eclipse.gmf.mappings.impl.MetricRuleImpl#getContainer <em>Container</em>}</li> * </ul> * </p> * * @generated */ public class MetricRuleImpl extends EObjectImpl implements MetricRule { /** * 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 #getDescription() <em>Description</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDescription() * @generated * @ordered */ protected static final String DESCRIPTION_EDEFAULT = null; /** * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDescription() * @generated * @ordered */ protected String description = DESCRIPTION_EDEFAULT; /** * The default value of the '{@link #getKey() <em>Key</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getKey() * @generated * @ordered */ protected static final String KEY_EDEFAULT = null; /** * The cached value of the '{@link #getKey() <em>Key</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getKey() * @generated * @ordered */ protected String key = KEY_EDEFAULT; /** * The cached value of the '{@link #getRule() <em>Rule</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getRule() * @generated * @ordered */ protected ValueExpression rule; /** * The cached value of the '{@link #getTarget() <em>Target</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTarget() * @generated * @ordered */ protected Measurable target; /** * The default value of the '{@link #getLowLimit() <em>Low Limit</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLowLimit() * @generated * @ordered */ protected static final Double LOW_LIMIT_EDEFAULT = null; /** * The cached value of the '{@link #getLowLimit() <em>Low Limit</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLowLimit() * @generated * @ordered */ protected Double lowLimit = LOW_LIMIT_EDEFAULT; /** * The default value of the '{@link #getHighLimit() <em>High Limit</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getHighLimit() * @generated * @ordered */ protected static final Double HIGH_LIMIT_EDEFAULT = null; /** * The cached value of the '{@link #getHighLimit() <em>High Limit</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getHighLimit() * @generated * @ordered */ protected Double highLimit = HIGH_LIMIT_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected MetricRuleImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return GMFMapPackage.eINSTANCE.getMetricRule(); } /** * <!-- 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, GMFMapPackage.METRIC_RULE__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getDescription() { return description; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setDescription(String newDescription) { String oldDescription = description; description = newDescription; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__DESCRIPTION, oldDescription, description)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getKey() { return key; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setKey(String newKey) { String oldKey = key; key = newKey; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__KEY, oldKey, key)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public ValueExpression getRule() { return rule; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetRule(ValueExpression newRule, NotificationChain msgs) { ValueExpression oldRule = rule; rule = newRule; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__RULE, oldRule, newRule); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRule(ValueExpression newRule) { if (newRule != rule) { NotificationChain msgs = null; if (rule != null) msgs = ((InternalEObject)rule).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.METRIC_RULE__RULE, null, msgs); if (newRule != null) msgs = ((InternalEObject)newRule).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.METRIC_RULE__RULE, null, msgs); msgs = basicSetRule(newRule, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__RULE, newRule, newRule)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Measurable getTarget() { return target; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTarget(Measurable newTarget, NotificationChain msgs) { Measurable oldTarget = target; target = newTarget; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__TARGET, oldTarget, newTarget); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTarget(Measurable newTarget) { if (newTarget != target) { NotificationChain msgs = null; if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.METRIC_RULE__TARGET, null, msgs); if (newTarget != null) msgs = ((InternalEObject)newTarget).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.METRIC_RULE__TARGET, null, msgs); msgs = basicSetTarget(newTarget, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__TARGET, newTarget, newTarget)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Double getLowLimit() { return lowLimit; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setLowLimit(Double newLowLimit) { Double oldLowLimit = lowLimit; lowLimit = newLowLimit; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__LOW_LIMIT, oldLowLimit, lowLimit)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Double getHighLimit() { return highLimit; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setHighLimit(Double newHighLimit) { Double oldHighLimit = highLimit; highLimit = newHighLimit; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__HIGH_LIMIT, oldHighLimit, highLimit)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public MetricContainer getContainer() { if (eContainerFeatureID() != GMFMapPackage.METRIC_RULE__CONTAINER) return null; return (MetricContainer)eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetContainer(MetricContainer newContainer, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newContainer, GMFMapPackage.METRIC_RULE__CONTAINER, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setContainer(MetricContainer newContainer) { if (newContainer != eInternalContainer() || (eContainerFeatureID() != GMFMapPackage.METRIC_RULE__CONTAINER && newContainer != null)) { if (EcoreUtil.isAncestor(this, newContainer)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newContainer != null) msgs = ((InternalEObject)newContainer).eInverseAdd(this, GMFMapPackage.METRIC_CONTAINER__METRICS, MetricContainer.class, msgs); msgs = basicSetContainer(newContainer, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.METRIC_RULE__CONTAINER, newContainer, newContainer)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case GMFMapPackage.METRIC_RULE__CONTAINER: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetContainer((MetricContainer)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 GMFMapPackage.METRIC_RULE__RULE: return basicSetRule(null, msgs); case GMFMapPackage.METRIC_RULE__TARGET: return basicSetTarget(null, msgs); case GMFMapPackage.METRIC_RULE__CONTAINER: return basicSetContainer(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case GMFMapPackage.METRIC_RULE__CONTAINER: return eInternalContainer().eInverseRemove(this, GMFMapPackage.METRIC_CONTAINER__METRICS, MetricContainer.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 GMFMapPackage.METRIC_RULE__NAME: return getName(); case GMFMapPackage.METRIC_RULE__DESCRIPTION: return getDescription(); case GMFMapPackage.METRIC_RULE__KEY: return getKey(); case GMFMapPackage.METRIC_RULE__RULE: return getRule(); case GMFMapPackage.METRIC_RULE__TARGET: return getTarget(); case GMFMapPackage.METRIC_RULE__LOW_LIMIT: return getLowLimit(); case GMFMapPackage.METRIC_RULE__HIGH_LIMIT: return getHighLimit(); case GMFMapPackage.METRIC_RULE__CONTAINER: return getContainer(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case GMFMapPackage.METRIC_RULE__NAME: setName((String)newValue); return; case GMFMapPackage.METRIC_RULE__DESCRIPTION: setDescription((String)newValue); return; case GMFMapPackage.METRIC_RULE__KEY: setKey((String)newValue); return; case GMFMapPackage.METRIC_RULE__RULE: setRule((ValueExpression)newValue); return; case GMFMapPackage.METRIC_RULE__TARGET: setTarget((Measurable)newValue); return; case GMFMapPackage.METRIC_RULE__LOW_LIMIT: setLowLimit((Double)newValue); return; case GMFMapPackage.METRIC_RULE__HIGH_LIMIT: setHighLimit((Double)newValue); return; case GMFMapPackage.METRIC_RULE__CONTAINER: setContainer((MetricContainer)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case GMFMapPackage.METRIC_RULE__NAME: setName(NAME_EDEFAULT); return; case GMFMapPackage.METRIC_RULE__DESCRIPTION: setDescription(DESCRIPTION_EDEFAULT); return; case GMFMapPackage.METRIC_RULE__KEY: setKey(KEY_EDEFAULT); return; case GMFMapPackage.METRIC_RULE__RULE: setRule((ValueExpression)null); return; case GMFMapPackage.METRIC_RULE__TARGET: setTarget((Measurable)null); return; case GMFMapPackage.METRIC_RULE__LOW_LIMIT: setLowLimit(LOW_LIMIT_EDEFAULT); return; case GMFMapPackage.METRIC_RULE__HIGH_LIMIT: setHighLimit(HIGH_LIMIT_EDEFAULT); return; case GMFMapPackage.METRIC_RULE__CONTAINER: setContainer((MetricContainer)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case GMFMapPackage.METRIC_RULE__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case GMFMapPackage.METRIC_RULE__DESCRIPTION: return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description); case GMFMapPackage.METRIC_RULE__KEY: return KEY_EDEFAULT == null ? key != null : !KEY_EDEFAULT.equals(key); case GMFMapPackage.METRIC_RULE__RULE: return rule != null; case GMFMapPackage.METRIC_RULE__TARGET: return target != null; case GMFMapPackage.METRIC_RULE__LOW_LIMIT: return LOW_LIMIT_EDEFAULT == null ? lowLimit != null : !LOW_LIMIT_EDEFAULT.equals(lowLimit); case GMFMapPackage.METRIC_RULE__HIGH_LIMIT: return HIGH_LIMIT_EDEFAULT == null ? highLimit != null : !HIGH_LIMIT_EDEFAULT.equals(highLimit); case GMFMapPackage.METRIC_RULE__CONTAINER: return getContainer() != 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(" (name: "); result.append(name); result.append(", description: "); result.append(description); result.append(", key: "); result.append(key); result.append(", lowLimit: "); result.append(lowLimit); result.append(", highLimit: "); result.append(highLimit); result.append(')'); return result.toString(); } } //MetricRuleImpl