source: branches/xtext-MDT/org.modelica.emf.units/src/PhysicalQuantities/impl/AlternativeUnitImpl.java @ 552

Last change on this file since 552 was 552, checked in by nasko, 15 years ago

Work in progress

File size: 7.6 KB
Line 
1/**
2 * <copyright>
3 * </copyright>
4 *
5 * $Id$
6 */
7package PhysicalQuantities.impl;
8
9import PhysicalQuantities.AlternativeUnit;
10import PhysicalQuantities.PhysicalQuantitiesPackage;
11import PhysicalQuantities.Unit;
12import PhysicalQuantities.UnitTransformation;
13
14import org.eclipse.emf.common.notify.Notification;
15import org.eclipse.emf.common.notify.NotificationChain;
16
17import org.eclipse.emf.ecore.EClass;
18import org.eclipse.emf.ecore.InternalEObject;
19
20import org.eclipse.emf.ecore.impl.ENotificationImpl;
21
22/**
23 * <!-- begin-user-doc -->
24 * An implementation of the model object '<em><b>Alternative Unit</b></em>'.
25 * <!-- end-user-doc -->
26 * <p>
27 * The following features are implemented:
28 * <ul>
29 *   <li>{@link PhysicalQuantities.impl.AlternativeUnitImpl#getBasisUnit <em>Basis Unit</em>}</li>
30 *   <li>{@link PhysicalQuantities.impl.AlternativeUnitImpl#getTransformationToBasisUnit <em>Transformation To Basis Unit</em>}</li>
31 * </ul>
32 * </p>
33 *
34 * @generated
35 */
36public class AlternativeUnitImpl extends BaseUnitImpl implements AlternativeUnit {
37    /**
38     * The cached value of the '{@link #getBasisUnit() <em>Basis Unit</em>}' containment reference.
39     * <!-- begin-user-doc -->
40     * <!-- end-user-doc -->
41     * @see #getBasisUnit()
42     * @generated
43     * @ordered
44     */
45    protected Unit basisUnit;
46
47    /**
48     * The cached value of the '{@link #getTransformationToBasisUnit() <em>Transformation To Basis Unit</em>}' containment reference.
49     * <!-- begin-user-doc -->
50     * <!-- end-user-doc -->
51     * @see #getTransformationToBasisUnit()
52     * @generated
53     * @ordered
54     */
55    protected UnitTransformation transformationToBasisUnit;
56
57    /**
58     * <!-- begin-user-doc -->
59     * <!-- end-user-doc -->
60     * @generated
61     */
62    protected AlternativeUnitImpl() {
63        super();
64    }
65
66    /**
67     * <!-- begin-user-doc -->
68     * <!-- end-user-doc -->
69     * @generated
70     */
71    @Override
72    protected EClass eStaticClass() {
73        return PhysicalQuantitiesPackage.Literals.ALTERNATIVE_UNIT;
74    }
75
76    /**
77     * <!-- begin-user-doc -->
78     * <!-- end-user-doc -->
79     * @generated
80     */
81    public Unit getBasisUnit() {
82        return basisUnit;
83    }
84
85    /**
86     * <!-- begin-user-doc -->
87     * <!-- end-user-doc -->
88     * @generated
89     */
90    public NotificationChain basicSetBasisUnit(Unit newBasisUnit, NotificationChain msgs) {
91        Unit oldBasisUnit = basisUnit;
92        basisUnit = newBasisUnit;
93        if (eNotificationRequired()) {
94            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT, oldBasisUnit, newBasisUnit);
95            if (msgs == null) msgs = notification; else msgs.add(notification);
96        }
97        return msgs;
98    }
99
100    /**
101     * <!-- begin-user-doc -->
102     * <!-- end-user-doc -->
103     * @generated
104     */
105    public void setBasisUnit(Unit newBasisUnit) {
106        if (newBasisUnit != basisUnit) {
107            NotificationChain msgs = null;
108            if (basisUnit != null)
109                msgs = ((InternalEObject)basisUnit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT, null, msgs);
110            if (newBasisUnit != null)
111                msgs = ((InternalEObject)newBasisUnit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT, null, msgs);
112            msgs = basicSetBasisUnit(newBasisUnit, msgs);
113            if (msgs != null) msgs.dispatch();
114        }
115        else if (eNotificationRequired())
116            eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT, newBasisUnit, newBasisUnit));
117    }
118
119    /**
120     * <!-- begin-user-doc -->
121     * <!-- end-user-doc -->
122     * @generated
123     */
124    public UnitTransformation getTransformationToBasisUnit() {
125        return transformationToBasisUnit;
126    }
127
128    /**
129     * <!-- begin-user-doc -->
130     * <!-- end-user-doc -->
131     * @generated
132     */
133    public NotificationChain basicSetTransformationToBasisUnit(UnitTransformation newTransformationToBasisUnit, NotificationChain msgs) {
134        UnitTransformation oldTransformationToBasisUnit = transformationToBasisUnit;
135        transformationToBasisUnit = newTransformationToBasisUnit;
136        if (eNotificationRequired()) {
137            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT, oldTransformationToBasisUnit, newTransformationToBasisUnit);
138            if (msgs == null) msgs = notification; else msgs.add(notification);
139        }
140        return msgs;
141    }
142
143    /**
144     * <!-- begin-user-doc -->
145     * <!-- end-user-doc -->
146     * @generated
147     */
148    public void setTransformationToBasisUnit(UnitTransformation newTransformationToBasisUnit) {
149        if (newTransformationToBasisUnit != transformationToBasisUnit) {
150            NotificationChain msgs = null;
151            if (transformationToBasisUnit != null)
152                msgs = ((InternalEObject)transformationToBasisUnit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT, null, msgs);
153            if (newTransformationToBasisUnit != null)
154                msgs = ((InternalEObject)newTransformationToBasisUnit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT, null, msgs);
155            msgs = basicSetTransformationToBasisUnit(newTransformationToBasisUnit, msgs);
156            if (msgs != null) msgs.dispatch();
157        }
158        else if (eNotificationRequired())
159            eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT, newTransformationToBasisUnit, newTransformationToBasisUnit));
160    }
161
162    /**
163     * <!-- begin-user-doc -->
164     * <!-- end-user-doc -->
165     * @generated
166     */
167    @Override
168    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
169        switch (featureID) {
170            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT:
171                return basicSetBasisUnit(null, msgs);
172            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT:
173                return basicSetTransformationToBasisUnit(null, msgs);
174        }
175        return super.eInverseRemove(otherEnd, featureID, msgs);
176    }
177
178    /**
179     * <!-- begin-user-doc -->
180     * <!-- end-user-doc -->
181     * @generated
182     */
183    @Override
184    public Object eGet(int featureID, boolean resolve, boolean coreType) {
185        switch (featureID) {
186            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT:
187                return getBasisUnit();
188            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT:
189                return getTransformationToBasisUnit();
190        }
191        return super.eGet(featureID, resolve, coreType);
192    }
193
194    /**
195     * <!-- begin-user-doc -->
196     * <!-- end-user-doc -->
197     * @generated
198     */
199    @Override
200    public void eSet(int featureID, Object newValue) {
201        switch (featureID) {
202            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT:
203                setBasisUnit((Unit)newValue);
204                return;
205            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT:
206                setTransformationToBasisUnit((UnitTransformation)newValue);
207                return;
208        }
209        super.eSet(featureID, newValue);
210    }
211
212    /**
213     * <!-- begin-user-doc -->
214     * <!-- end-user-doc -->
215     * @generated
216     */
217    @Override
218    public void eUnset(int featureID) {
219        switch (featureID) {
220            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT:
221                setBasisUnit((Unit)null);
222                return;
223            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT:
224                setTransformationToBasisUnit((UnitTransformation)null);
225                return;
226        }
227        super.eUnset(featureID);
228    }
229
230    /**
231     * <!-- begin-user-doc -->
232     * <!-- end-user-doc -->
233     * @generated
234     */
235    @Override
236    public boolean eIsSet(int featureID) {
237        switch (featureID) {
238            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__BASIS_UNIT:
239                return basisUnit != null;
240            case PhysicalQuantitiesPackage.ALTERNATIVE_UNIT__TRANSFORMATION_TO_BASIS_UNIT:
241                return transformationToBasisUnit != null;
242        }
243        return super.eIsSet(featureID);
244    }
245
246} //AlternativeUnitImpl
Note: See TracBrowser for help on using the repository browser.