1 | /** |
---|
2 | * <copyright> |
---|
3 | * </copyright> |
---|
4 | * |
---|
5 | * $Id$ |
---|
6 | */ |
---|
7 | package PhysicalQuantities.impl; |
---|
8 | |
---|
9 | import PhysicalQuantities.AlternativeUnit; |
---|
10 | import PhysicalQuantities.DerivedUnit; |
---|
11 | import PhysicalQuantities.PhysicalQuantitiesPackage; |
---|
12 | import PhysicalQuantities.Quantity; |
---|
13 | import PhysicalQuantities.Unit; |
---|
14 | |
---|
15 | import java.util.Collection; |
---|
16 | |
---|
17 | import org.eclipse.emf.common.notify.Notification; |
---|
18 | import org.eclipse.emf.common.notify.NotificationChain; |
---|
19 | |
---|
20 | import org.eclipse.emf.common.util.EList; |
---|
21 | |
---|
22 | import org.eclipse.emf.ecore.EClass; |
---|
23 | import org.eclipse.emf.ecore.InternalEObject; |
---|
24 | |
---|
25 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
---|
26 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
---|
27 | |
---|
28 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
---|
29 | import org.eclipse.emf.ecore.util.InternalEList; |
---|
30 | |
---|
31 | /** |
---|
32 | * <!-- begin-user-doc --> |
---|
33 | * An implementation of the model object '<em><b>Quantity</b></em>'. |
---|
34 | * <!-- end-user-doc --> |
---|
35 | * <p> |
---|
36 | * The following features are implemented: |
---|
37 | * <ul> |
---|
38 | * <li>{@link PhysicalQuantities.impl.QuantityImpl#getUnit <em>Unit</em>}</li> |
---|
39 | * <li>{@link PhysicalQuantities.impl.QuantityImpl#getAlternativeUnits <em>Alternative Units</em>}</li> |
---|
40 | * <li>{@link PhysicalQuantities.impl.QuantityImpl#getDerivedUnits <em>Derived Units</em>}</li> |
---|
41 | * <li>{@link PhysicalQuantities.impl.QuantityImpl#getName <em>Name</em>}</li> |
---|
42 | * <li>{@link PhysicalQuantities.impl.QuantityImpl#getDescriptiveName <em>Descriptive Name</em>}</li> |
---|
43 | * <li>{@link PhysicalQuantities.impl.QuantityImpl#getSymbol <em>Symbol</em>}</li> |
---|
44 | * </ul> |
---|
45 | * </p> |
---|
46 | * |
---|
47 | * @generated |
---|
48 | */ |
---|
49 | public class QuantityImpl extends EObjectImpl implements Quantity { |
---|
50 | /** |
---|
51 | * The cached value of the '{@link #getUnit() <em>Unit</em>}' containment reference. |
---|
52 | * <!-- begin-user-doc --> |
---|
53 | * <!-- end-user-doc --> |
---|
54 | * @see #getUnit() |
---|
55 | * @generated |
---|
56 | * @ordered |
---|
57 | */ |
---|
58 | protected Unit unit; |
---|
59 | |
---|
60 | /** |
---|
61 | * The cached value of the '{@link #getAlternativeUnits() <em>Alternative Units</em>}' containment reference. |
---|
62 | * <!-- begin-user-doc --> |
---|
63 | * <!-- end-user-doc --> |
---|
64 | * @see #getAlternativeUnits() |
---|
65 | * @generated |
---|
66 | * @ordered |
---|
67 | */ |
---|
68 | protected AlternativeUnit alternativeUnits; |
---|
69 | |
---|
70 | /** |
---|
71 | * The cached value of the '{@link #getDerivedUnits() <em>Derived Units</em>}' containment reference list. |
---|
72 | * <!-- begin-user-doc --> |
---|
73 | * <!-- end-user-doc --> |
---|
74 | * @see #getDerivedUnits() |
---|
75 | * @generated |
---|
76 | * @ordered |
---|
77 | */ |
---|
78 | protected EList<DerivedUnit> derivedUnits; |
---|
79 | |
---|
80 | /** |
---|
81 | * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
---|
82 | * <!-- begin-user-doc --> |
---|
83 | * <!-- end-user-doc --> |
---|
84 | * @see #getName() |
---|
85 | * @generated |
---|
86 | * @ordered |
---|
87 | */ |
---|
88 | protected static final String NAME_EDEFAULT = null; |
---|
89 | |
---|
90 | /** |
---|
91 | * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
---|
92 | * <!-- begin-user-doc --> |
---|
93 | * <!-- end-user-doc --> |
---|
94 | * @see #getName() |
---|
95 | * @generated |
---|
96 | * @ordered |
---|
97 | */ |
---|
98 | protected String name = NAME_EDEFAULT; |
---|
99 | |
---|
100 | /** |
---|
101 | * The default value of the '{@link #getDescriptiveName() <em>Descriptive Name</em>}' attribute. |
---|
102 | * <!-- begin-user-doc --> |
---|
103 | * <!-- end-user-doc --> |
---|
104 | * @see #getDescriptiveName() |
---|
105 | * @generated |
---|
106 | * @ordered |
---|
107 | */ |
---|
108 | protected static final String DESCRIPTIVE_NAME_EDEFAULT = null; |
---|
109 | |
---|
110 | /** |
---|
111 | * The cached value of the '{@link #getDescriptiveName() <em>Descriptive Name</em>}' attribute. |
---|
112 | * <!-- begin-user-doc --> |
---|
113 | * <!-- end-user-doc --> |
---|
114 | * @see #getDescriptiveName() |
---|
115 | * @generated |
---|
116 | * @ordered |
---|
117 | */ |
---|
118 | protected String descriptiveName = DESCRIPTIVE_NAME_EDEFAULT; |
---|
119 | |
---|
120 | /** |
---|
121 | * The default value of the '{@link #getSymbol() <em>Symbol</em>}' attribute. |
---|
122 | * <!-- begin-user-doc --> |
---|
123 | * <!-- end-user-doc --> |
---|
124 | * @see #getSymbol() |
---|
125 | * @generated |
---|
126 | * @ordered |
---|
127 | */ |
---|
128 | protected static final String SYMBOL_EDEFAULT = null; |
---|
129 | |
---|
130 | /** |
---|
131 | * The cached value of the '{@link #getSymbol() <em>Symbol</em>}' attribute. |
---|
132 | * <!-- begin-user-doc --> |
---|
133 | * <!-- end-user-doc --> |
---|
134 | * @see #getSymbol() |
---|
135 | * @generated |
---|
136 | * @ordered |
---|
137 | */ |
---|
138 | protected String symbol = SYMBOL_EDEFAULT; |
---|
139 | |
---|
140 | /** |
---|
141 | * <!-- begin-user-doc --> |
---|
142 | * <!-- end-user-doc --> |
---|
143 | * @generated |
---|
144 | */ |
---|
145 | protected QuantityImpl() { |
---|
146 | super(); |
---|
147 | } |
---|
148 | |
---|
149 | /** |
---|
150 | * <!-- begin-user-doc --> |
---|
151 | * <!-- end-user-doc --> |
---|
152 | * @generated |
---|
153 | */ |
---|
154 | @Override |
---|
155 | protected EClass eStaticClass() { |
---|
156 | return PhysicalQuantitiesPackage.Literals.QUANTITY; |
---|
157 | } |
---|
158 | |
---|
159 | /** |
---|
160 | * <!-- begin-user-doc --> |
---|
161 | * <!-- end-user-doc --> |
---|
162 | * @generated |
---|
163 | */ |
---|
164 | public Unit getUnit() { |
---|
165 | return unit; |
---|
166 | } |
---|
167 | |
---|
168 | /** |
---|
169 | * <!-- begin-user-doc --> |
---|
170 | * <!-- end-user-doc --> |
---|
171 | * @generated |
---|
172 | */ |
---|
173 | public NotificationChain basicSetUnit(Unit newUnit, NotificationChain msgs) { |
---|
174 | Unit oldUnit = unit; |
---|
175 | unit = newUnit; |
---|
176 | if (eNotificationRequired()) { |
---|
177 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__UNIT, oldUnit, newUnit); |
---|
178 | if (msgs == null) msgs = notification; else msgs.add(notification); |
---|
179 | } |
---|
180 | return msgs; |
---|
181 | } |
---|
182 | |
---|
183 | /** |
---|
184 | * <!-- begin-user-doc --> |
---|
185 | * <!-- end-user-doc --> |
---|
186 | * @generated |
---|
187 | */ |
---|
188 | public void setUnit(Unit newUnit) { |
---|
189 | if (newUnit != unit) { |
---|
190 | NotificationChain msgs = null; |
---|
191 | if (unit != null) |
---|
192 | msgs = ((InternalEObject)unit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.QUANTITY__UNIT, null, msgs); |
---|
193 | if (newUnit != null) |
---|
194 | msgs = ((InternalEObject)newUnit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.QUANTITY__UNIT, null, msgs); |
---|
195 | msgs = basicSetUnit(newUnit, msgs); |
---|
196 | if (msgs != null) msgs.dispatch(); |
---|
197 | } |
---|
198 | else if (eNotificationRequired()) |
---|
199 | eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__UNIT, newUnit, newUnit)); |
---|
200 | } |
---|
201 | |
---|
202 | /** |
---|
203 | * <!-- begin-user-doc --> |
---|
204 | * <!-- end-user-doc --> |
---|
205 | * @generated |
---|
206 | */ |
---|
207 | public AlternativeUnit getAlternativeUnits() { |
---|
208 | return alternativeUnits; |
---|
209 | } |
---|
210 | |
---|
211 | /** |
---|
212 | * <!-- begin-user-doc --> |
---|
213 | * <!-- end-user-doc --> |
---|
214 | * @generated |
---|
215 | */ |
---|
216 | public NotificationChain basicSetAlternativeUnits(AlternativeUnit newAlternativeUnits, NotificationChain msgs) { |
---|
217 | AlternativeUnit oldAlternativeUnits = alternativeUnits; |
---|
218 | alternativeUnits = newAlternativeUnits; |
---|
219 | if (eNotificationRequired()) { |
---|
220 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS, oldAlternativeUnits, newAlternativeUnits); |
---|
221 | if (msgs == null) msgs = notification; else msgs.add(notification); |
---|
222 | } |
---|
223 | return msgs; |
---|
224 | } |
---|
225 | |
---|
226 | /** |
---|
227 | * <!-- begin-user-doc --> |
---|
228 | * <!-- end-user-doc --> |
---|
229 | * @generated |
---|
230 | */ |
---|
231 | public void setAlternativeUnits(AlternativeUnit newAlternativeUnits) { |
---|
232 | if (newAlternativeUnits != alternativeUnits) { |
---|
233 | NotificationChain msgs = null; |
---|
234 | if (alternativeUnits != null) |
---|
235 | msgs = ((InternalEObject)alternativeUnits).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS, null, msgs); |
---|
236 | if (newAlternativeUnits != null) |
---|
237 | msgs = ((InternalEObject)newAlternativeUnits).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS, null, msgs); |
---|
238 | msgs = basicSetAlternativeUnits(newAlternativeUnits, msgs); |
---|
239 | if (msgs != null) msgs.dispatch(); |
---|
240 | } |
---|
241 | else if (eNotificationRequired()) |
---|
242 | eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS, newAlternativeUnits, newAlternativeUnits)); |
---|
243 | } |
---|
244 | |
---|
245 | /** |
---|
246 | * <!-- begin-user-doc --> |
---|
247 | * <!-- end-user-doc --> |
---|
248 | * @generated |
---|
249 | */ |
---|
250 | public EList<DerivedUnit> getDerivedUnits() { |
---|
251 | if (derivedUnits == null) { |
---|
252 | derivedUnits = new EObjectContainmentEList<DerivedUnit>(DerivedUnit.class, this, PhysicalQuantitiesPackage.QUANTITY__DERIVED_UNITS); |
---|
253 | } |
---|
254 | return derivedUnits; |
---|
255 | } |
---|
256 | |
---|
257 | /** |
---|
258 | * <!-- begin-user-doc --> |
---|
259 | * <!-- end-user-doc --> |
---|
260 | * @generated |
---|
261 | */ |
---|
262 | public String getName() { |
---|
263 | return name; |
---|
264 | } |
---|
265 | |
---|
266 | /** |
---|
267 | * <!-- begin-user-doc --> |
---|
268 | * <!-- end-user-doc --> |
---|
269 | * @generated |
---|
270 | */ |
---|
271 | public void setName(String newName) { |
---|
272 | String oldName = name; |
---|
273 | name = newName; |
---|
274 | if (eNotificationRequired()) |
---|
275 | eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__NAME, oldName, name)); |
---|
276 | } |
---|
277 | |
---|
278 | /** |
---|
279 | * <!-- begin-user-doc --> |
---|
280 | * <!-- end-user-doc --> |
---|
281 | * @generated |
---|
282 | */ |
---|
283 | public String getDescriptiveName() { |
---|
284 | return descriptiveName; |
---|
285 | } |
---|
286 | |
---|
287 | /** |
---|
288 | * <!-- begin-user-doc --> |
---|
289 | * <!-- end-user-doc --> |
---|
290 | * @generated |
---|
291 | */ |
---|
292 | public void setDescriptiveName(String newDescriptiveName) { |
---|
293 | String oldDescriptiveName = descriptiveName; |
---|
294 | descriptiveName = newDescriptiveName; |
---|
295 | if (eNotificationRequired()) |
---|
296 | eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__DESCRIPTIVE_NAME, oldDescriptiveName, descriptiveName)); |
---|
297 | } |
---|
298 | |
---|
299 | /** |
---|
300 | * <!-- begin-user-doc --> |
---|
301 | * <!-- end-user-doc --> |
---|
302 | * @generated |
---|
303 | */ |
---|
304 | public String getSymbol() { |
---|
305 | return symbol; |
---|
306 | } |
---|
307 | |
---|
308 | /** |
---|
309 | * <!-- begin-user-doc --> |
---|
310 | * <!-- end-user-doc --> |
---|
311 | * @generated |
---|
312 | */ |
---|
313 | public void setSymbol(String newSymbol) { |
---|
314 | String oldSymbol = symbol; |
---|
315 | symbol = newSymbol; |
---|
316 | if (eNotificationRequired()) |
---|
317 | eNotify(new ENotificationImpl(this, Notification.SET, PhysicalQuantitiesPackage.QUANTITY__SYMBOL, oldSymbol, symbol)); |
---|
318 | } |
---|
319 | |
---|
320 | /** |
---|
321 | * <!-- begin-user-doc --> |
---|
322 | * <!-- end-user-doc --> |
---|
323 | * @generated |
---|
324 | */ |
---|
325 | @Override |
---|
326 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
---|
327 | switch (featureID) { |
---|
328 | case PhysicalQuantitiesPackage.QUANTITY__UNIT: |
---|
329 | return basicSetUnit(null, msgs); |
---|
330 | case PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS: |
---|
331 | return basicSetAlternativeUnits(null, msgs); |
---|
332 | case PhysicalQuantitiesPackage.QUANTITY__DERIVED_UNITS: |
---|
333 | return ((InternalEList<?>)getDerivedUnits()).basicRemove(otherEnd, msgs); |
---|
334 | } |
---|
335 | return super.eInverseRemove(otherEnd, featureID, msgs); |
---|
336 | } |
---|
337 | |
---|
338 | /** |
---|
339 | * <!-- begin-user-doc --> |
---|
340 | * <!-- end-user-doc --> |
---|
341 | * @generated |
---|
342 | */ |
---|
343 | @Override |
---|
344 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
---|
345 | switch (featureID) { |
---|
346 | case PhysicalQuantitiesPackage.QUANTITY__UNIT: |
---|
347 | return getUnit(); |
---|
348 | case PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS: |
---|
349 | return getAlternativeUnits(); |
---|
350 | case PhysicalQuantitiesPackage.QUANTITY__DERIVED_UNITS: |
---|
351 | return getDerivedUnits(); |
---|
352 | case PhysicalQuantitiesPackage.QUANTITY__NAME: |
---|
353 | return getName(); |
---|
354 | case PhysicalQuantitiesPackage.QUANTITY__DESCRIPTIVE_NAME: |
---|
355 | return getDescriptiveName(); |
---|
356 | case PhysicalQuantitiesPackage.QUANTITY__SYMBOL: |
---|
357 | return getSymbol(); |
---|
358 | } |
---|
359 | return super.eGet(featureID, resolve, coreType); |
---|
360 | } |
---|
361 | |
---|
362 | /** |
---|
363 | * <!-- begin-user-doc --> |
---|
364 | * <!-- end-user-doc --> |
---|
365 | * @generated |
---|
366 | */ |
---|
367 | @SuppressWarnings("unchecked") |
---|
368 | @Override |
---|
369 | public void eSet(int featureID, Object newValue) { |
---|
370 | switch (featureID) { |
---|
371 | case PhysicalQuantitiesPackage.QUANTITY__UNIT: |
---|
372 | setUnit((Unit)newValue); |
---|
373 | return; |
---|
374 | case PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS: |
---|
375 | setAlternativeUnits((AlternativeUnit)newValue); |
---|
376 | return; |
---|
377 | case PhysicalQuantitiesPackage.QUANTITY__DERIVED_UNITS: |
---|
378 | getDerivedUnits().clear(); |
---|
379 | getDerivedUnits().addAll((Collection<? extends DerivedUnit>)newValue); |
---|
380 | return; |
---|
381 | case PhysicalQuantitiesPackage.QUANTITY__NAME: |
---|
382 | setName((String)newValue); |
---|
383 | return; |
---|
384 | case PhysicalQuantitiesPackage.QUANTITY__DESCRIPTIVE_NAME: |
---|
385 | setDescriptiveName((String)newValue); |
---|
386 | return; |
---|
387 | case PhysicalQuantitiesPackage.QUANTITY__SYMBOL: |
---|
388 | setSymbol((String)newValue); |
---|
389 | return; |
---|
390 | } |
---|
391 | super.eSet(featureID, newValue); |
---|
392 | } |
---|
393 | |
---|
394 | /** |
---|
395 | * <!-- begin-user-doc --> |
---|
396 | * <!-- end-user-doc --> |
---|
397 | * @generated |
---|
398 | */ |
---|
399 | @Override |
---|
400 | public void eUnset(int featureID) { |
---|
401 | switch (featureID) { |
---|
402 | case PhysicalQuantitiesPackage.QUANTITY__UNIT: |
---|
403 | setUnit((Unit)null); |
---|
404 | return; |
---|
405 | case PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS: |
---|
406 | setAlternativeUnits((AlternativeUnit)null); |
---|
407 | return; |
---|
408 | case PhysicalQuantitiesPackage.QUANTITY__DERIVED_UNITS: |
---|
409 | getDerivedUnits().clear(); |
---|
410 | return; |
---|
411 | case PhysicalQuantitiesPackage.QUANTITY__NAME: |
---|
412 | setName(NAME_EDEFAULT); |
---|
413 | return; |
---|
414 | case PhysicalQuantitiesPackage.QUANTITY__DESCRIPTIVE_NAME: |
---|
415 | setDescriptiveName(DESCRIPTIVE_NAME_EDEFAULT); |
---|
416 | return; |
---|
417 | case PhysicalQuantitiesPackage.QUANTITY__SYMBOL: |
---|
418 | setSymbol(SYMBOL_EDEFAULT); |
---|
419 | return; |
---|
420 | } |
---|
421 | super.eUnset(featureID); |
---|
422 | } |
---|
423 | |
---|
424 | /** |
---|
425 | * <!-- begin-user-doc --> |
---|
426 | * <!-- end-user-doc --> |
---|
427 | * @generated |
---|
428 | */ |
---|
429 | @Override |
---|
430 | public boolean eIsSet(int featureID) { |
---|
431 | switch (featureID) { |
---|
432 | case PhysicalQuantitiesPackage.QUANTITY__UNIT: |
---|
433 | return unit != null; |
---|
434 | case PhysicalQuantitiesPackage.QUANTITY__ALTERNATIVE_UNITS: |
---|
435 | return alternativeUnits != null; |
---|
436 | case PhysicalQuantitiesPackage.QUANTITY__DERIVED_UNITS: |
---|
437 | return derivedUnits != null && !derivedUnits.isEmpty(); |
---|
438 | case PhysicalQuantitiesPackage.QUANTITY__NAME: |
---|
439 | return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
---|
440 | case PhysicalQuantitiesPackage.QUANTITY__DESCRIPTIVE_NAME: |
---|
441 | return DESCRIPTIVE_NAME_EDEFAULT == null ? descriptiveName != null : !DESCRIPTIVE_NAME_EDEFAULT.equals(descriptiveName); |
---|
442 | case PhysicalQuantitiesPackage.QUANTITY__SYMBOL: |
---|
443 | return SYMBOL_EDEFAULT == null ? symbol != null : !SYMBOL_EDEFAULT.equals(symbol); |
---|
444 | } |
---|
445 | return super.eIsSet(featureID); |
---|
446 | } |
---|
447 | |
---|
448 | /** |
---|
449 | * <!-- begin-user-doc --> |
---|
450 | * <!-- end-user-doc --> |
---|
451 | * @generated |
---|
452 | */ |
---|
453 | @Override |
---|
454 | public String toString() { |
---|
455 | if (eIsProxy()) return super.toString(); |
---|
456 | |
---|
457 | StringBuffer result = new StringBuffer(super.toString()); |
---|
458 | result.append(" (name: "); |
---|
459 | result.append(name); |
---|
460 | result.append(", descriptiveName: "); |
---|
461 | result.append(descriptiveName); |
---|
462 | result.append(", symbol: "); |
---|
463 | result.append(symbol); |
---|
464 | result.append(')'); |
---|
465 | return result.toString(); |
---|
466 | } |
---|
467 | |
---|
468 | } //QuantityImpl |
---|