/** | |
* Copyright (c) 2010 Mia-Software. | |
* 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: | |
* Nicolas Payneau (Mia-Software) - initial API and implementation | |
*/ | |
package org.eclipse.modisco.omg.smm.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.util.EObjectWithInverseResolvingEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
import org.eclipse.modisco.omg.smm.Accumulator; | |
import org.eclipse.modisco.omg.smm.BaseMeasureRelationship; | |
import org.eclipse.modisco.omg.smm.CollectiveMeasure; | |
import org.eclipse.modisco.omg.smm.SmmPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Collective Measure</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.modisco.omg.smm.impl.CollectiveMeasureImpl#getAccumulator <em>Accumulator</em>}</li> | |
* <li>{@link org.eclipse.modisco.omg.smm.impl.CollectiveMeasureImpl#getBaseMeasureTo <em>Base Measure To</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class CollectiveMeasureImpl extends DimensionalMeasureImpl implements CollectiveMeasure { | |
/** | |
* The default value of the '{@link #getAccumulator() <em>Accumulator</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getAccumulator() | |
* @generated | |
* @ordered | |
*/ | |
protected static final Accumulator ACCUMULATOR_EDEFAULT = Accumulator.SUM; | |
/** | |
* The cached value of the '{@link #getAccumulator() <em>Accumulator</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getAccumulator() | |
* @generated | |
* @ordered | |
*/ | |
protected Accumulator accumulator = ACCUMULATOR_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getBaseMeasureTo() <em>Base Measure To</em>}' reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getBaseMeasureTo() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<BaseMeasureRelationship> baseMeasureTo; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected CollectiveMeasureImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return SmmPackage.Literals.COLLECTIVE_MEASURE; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Accumulator getAccumulator() { | |
return accumulator; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setAccumulator(Accumulator newAccumulator) { | |
Accumulator oldAccumulator = accumulator; | |
accumulator = newAccumulator == null ? ACCUMULATOR_EDEFAULT : newAccumulator; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.COLLECTIVE_MEASURE__ACCUMULATOR, oldAccumulator, accumulator)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<BaseMeasureRelationship> getBaseMeasureTo() { | |
if (baseMeasureTo == null) { | |
baseMeasureTo = new EObjectWithInverseResolvingEList<BaseMeasureRelationship>(BaseMeasureRelationship.class, this, SmmPackage.COLLECTIVE_MEASURE__BASE_MEASURE_TO, SmmPackage.BASE_MEASURE_RELATIONSHIP__FROM); | |
} | |
return baseMeasureTo; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case SmmPackage.COLLECTIVE_MEASURE__BASE_MEASURE_TO: | |
return ((InternalEList<InternalEObject>)(InternalEList<?>)getBaseMeasureTo()).basicAdd(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.COLLECTIVE_MEASURE__BASE_MEASURE_TO: | |
return ((InternalEList<?>)getBaseMeasureTo()).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 SmmPackage.COLLECTIVE_MEASURE__ACCUMULATOR: | |
return getAccumulator(); | |
case SmmPackage.COLLECTIVE_MEASURE__BASE_MEASURE_TO: | |
return getBaseMeasureTo(); | |
} | |
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 SmmPackage.COLLECTIVE_MEASURE__ACCUMULATOR: | |
setAccumulator((Accumulator)newValue); | |
return; | |
case SmmPackage.COLLECTIVE_MEASURE__BASE_MEASURE_TO: | |
getBaseMeasureTo().clear(); | |
getBaseMeasureTo().addAll((Collection<? extends BaseMeasureRelationship>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case SmmPackage.COLLECTIVE_MEASURE__ACCUMULATOR: | |
setAccumulator(ACCUMULATOR_EDEFAULT); | |
return; | |
case SmmPackage.COLLECTIVE_MEASURE__BASE_MEASURE_TO: | |
getBaseMeasureTo().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case SmmPackage.COLLECTIVE_MEASURE__ACCUMULATOR: | |
return accumulator != ACCUMULATOR_EDEFAULT; | |
case SmmPackage.COLLECTIVE_MEASURE__BASE_MEASURE_TO: | |
return baseMeasureTo != null && !baseMeasureTo.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(" (accumulator: "); | |
result.append(accumulator); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //CollectiveMeasureImpl |