1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.fzi.se.quality.parameters.impl; |
8 | |
9 | import de.fzi.se.quality.parameters.CallInstance; |
10 | import de.fzi.se.quality.parameters.OperationReference; |
11 | import de.fzi.se.quality.parameters.ParameterInstance; |
12 | import de.fzi.se.quality.parameters.ParametersPackage; |
13 | |
14 | import de.uka.ipd.sdq.identifier.impl.IdentifierImpl; |
15 | |
16 | import java.util.Collection; |
17 | |
18 | import org.eclipse.emf.common.notify.Notification; |
19 | import org.eclipse.emf.common.notify.NotificationChain; |
20 | |
21 | import org.eclipse.emf.common.util.EList; |
22 | |
23 | import org.eclipse.emf.ecore.EClass; |
24 | import org.eclipse.emf.ecore.InternalEObject; |
25 | |
26 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
27 | |
28 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
29 | import org.eclipse.emf.ecore.util.InternalEList; |
30 | |
31 | /** |
32 | * <!-- begin-user-doc --> |
33 | * An implementation of the model object '<em><b>Call Instance</b></em>'. |
34 | * <!-- end-user-doc --> |
35 | * <p> |
36 | * The following features are implemented: |
37 | * <ul> |
38 | * <li>{@link de.fzi.se.quality.parameters.impl.CallInstanceImpl#getOperationReference <em>Operation Reference</em>}</li> |
39 | * <li>{@link de.fzi.se.quality.parameters.impl.CallInstanceImpl#getOutputParameterInstances <em>Output Parameter Instances</em>}</li> |
40 | * <li>{@link de.fzi.se.quality.parameters.impl.CallInstanceImpl#getNumberOfCalls <em>Number Of Calls</em>}</li> |
41 | * <li>{@link de.fzi.se.quality.parameters.impl.CallInstanceImpl#getInputParameterInstances <em>Input Parameter Instances</em>}</li> |
42 | * </ul> |
43 | * </p> |
44 | * |
45 | * @generated |
46 | */ |
47 | public class CallInstanceImpl extends IdentifierImpl implements CallInstance { |
48 | /** |
49 | * The cached value of the '{@link #getOperationReference() <em>Operation Reference</em>}' containment reference. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @see #getOperationReference() |
53 | * @generated |
54 | * @ordered |
55 | */ |
56 | protected OperationReference operationReference; |
57 | |
58 | /** |
59 | * The cached value of the '{@link #getOutputParameterInstances() <em>Output Parameter Instances</em>}' containment reference list. |
60 | * <!-- begin-user-doc --> |
61 | * <!-- end-user-doc --> |
62 | * @see #getOutputParameterInstances() |
63 | * @generated |
64 | * @ordered |
65 | */ |
66 | protected EList<ParameterInstance> outputParameterInstances; |
67 | |
68 | /** |
69 | * The default value of the '{@link #getNumberOfCalls() <em>Number Of Calls</em>}' attribute. |
70 | * <!-- begin-user-doc --> |
71 | * <!-- end-user-doc --> |
72 | * @see #getNumberOfCalls() |
73 | * @generated |
74 | * @ordered |
75 | */ |
76 | protected static final long NUMBER_OF_CALLS_EDEFAULT = 1L; |
77 | |
78 | /** |
79 | * The cached value of the '{@link #getNumberOfCalls() <em>Number Of Calls</em>}' attribute. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @see #getNumberOfCalls() |
83 | * @generated |
84 | * @ordered |
85 | */ |
86 | protected long numberOfCalls = NUMBER_OF_CALLS_EDEFAULT; |
87 | |
88 | /** |
89 | * The cached value of the '{@link #getInputParameterInstances() <em>Input Parameter Instances</em>}' containment reference list. |
90 | * <!-- begin-user-doc --> |
91 | * <!-- end-user-doc --> |
92 | * @see #getInputParameterInstances() |
93 | * @generated |
94 | * @ordered |
95 | */ |
96 | protected EList<ParameterInstance> inputParameterInstances; |
97 | |
98 | /** |
99 | * <!-- begin-user-doc --> |
100 | * <!-- end-user-doc --> |
101 | * @generated |
102 | */ |
103 | protected CallInstanceImpl() { |
104 | super(); |
105 | } |
106 | |
107 | /** |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | @Override |
113 | protected EClass eStaticClass() { |
114 | return ParametersPackage.Literals.CALL_INSTANCE; |
115 | } |
116 | |
117 | /** |
118 | * <!-- begin-user-doc --> |
119 | * <!-- end-user-doc --> |
120 | * @generated |
121 | */ |
122 | public OperationReference getOperationReference() { |
123 | return operationReference; |
124 | } |
125 | |
126 | /** |
127 | * <!-- begin-user-doc --> |
128 | * <!-- end-user-doc --> |
129 | * @generated |
130 | */ |
131 | public NotificationChain basicSetOperationReference(OperationReference newOperationReference, NotificationChain msgs) { |
132 | OperationReference oldOperationReference = operationReference; |
133 | operationReference = newOperationReference; |
134 | if (eNotificationRequired()) { |
135 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE, oldOperationReference, newOperationReference); |
136 | if (msgs == null) msgs = notification; else msgs.add(notification); |
137 | } |
138 | return msgs; |
139 | } |
140 | |
141 | /** |
142 | * <!-- begin-user-doc --> |
143 | * <!-- end-user-doc --> |
144 | * @generated |
145 | */ |
146 | public void setOperationReference(OperationReference newOperationReference) { |
147 | if (newOperationReference != operationReference) { |
148 | NotificationChain msgs = null; |
149 | if (operationReference != null) |
150 | msgs = ((InternalEObject)operationReference).eInverseRemove(this, ParametersPackage.OPERATION_REFERENCE__CALL_INSTANCE, OperationReference.class, msgs); |
151 | if (newOperationReference != null) |
152 | msgs = ((InternalEObject)newOperationReference).eInverseAdd(this, ParametersPackage.OPERATION_REFERENCE__CALL_INSTANCE, OperationReference.class, msgs); |
153 | msgs = basicSetOperationReference(newOperationReference, msgs); |
154 | if (msgs != null) msgs.dispatch(); |
155 | } |
156 | else if (eNotificationRequired()) |
157 | eNotify(new ENotificationImpl(this, Notification.SET, ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE, newOperationReference, newOperationReference)); |
158 | } |
159 | |
160 | /** |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | public EList<ParameterInstance> getOutputParameterInstances() { |
166 | if (outputParameterInstances == null) { |
167 | outputParameterInstances = new EObjectContainmentWithInverseEList<ParameterInstance>(ParameterInstance.class, this, ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES, ParametersPackage.PARAMETER_INSTANCE__OUTPUT_CALL_INSTANCE); |
168 | } |
169 | return outputParameterInstances; |
170 | } |
171 | |
172 | /** |
173 | * <!-- begin-user-doc --> |
174 | * <!-- end-user-doc --> |
175 | * @generated |
176 | */ |
177 | public long getNumberOfCalls() { |
178 | return numberOfCalls; |
179 | } |
180 | |
181 | /** |
182 | * <!-- begin-user-doc --> |
183 | * <!-- end-user-doc --> |
184 | * @generated |
185 | */ |
186 | public void setNumberOfCalls(long newNumberOfCalls) { |
187 | long oldNumberOfCalls = numberOfCalls; |
188 | numberOfCalls = newNumberOfCalls; |
189 | if (eNotificationRequired()) |
190 | eNotify(new ENotificationImpl(this, Notification.SET, ParametersPackage.CALL_INSTANCE__NUMBER_OF_CALLS, oldNumberOfCalls, numberOfCalls)); |
191 | } |
192 | |
193 | /** |
194 | * <!-- begin-user-doc --> |
195 | * <!-- end-user-doc --> |
196 | * @generated |
197 | */ |
198 | public EList<ParameterInstance> getInputParameterInstances() { |
199 | if (inputParameterInstances == null) { |
200 | inputParameterInstances = new EObjectContainmentWithInverseEList<ParameterInstance>(ParameterInstance.class, this, ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES, ParametersPackage.PARAMETER_INSTANCE__INPUT_CALL_INSTANCE); |
201 | } |
202 | return inputParameterInstances; |
203 | } |
204 | |
205 | /** |
206 | * <!-- begin-user-doc --> |
207 | * <!-- end-user-doc --> |
208 | * @generated |
209 | */ |
210 | @SuppressWarnings("unchecked") |
211 | @Override |
212 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
213 | switch (featureID) { |
214 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
215 | if (operationReference != null) |
216 | msgs = ((InternalEObject)operationReference).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE, null, msgs); |
217 | return basicSetOperationReference((OperationReference)otherEnd, msgs); |
218 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
219 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutputParameterInstances()).basicAdd(otherEnd, msgs); |
220 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
221 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getInputParameterInstances()).basicAdd(otherEnd, msgs); |
222 | } |
223 | return super.eInverseAdd(otherEnd, featureID, msgs); |
224 | } |
225 | |
226 | /** |
227 | * <!-- begin-user-doc --> |
228 | * <!-- end-user-doc --> |
229 | * @generated |
230 | */ |
231 | @Override |
232 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
233 | switch (featureID) { |
234 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
235 | return basicSetOperationReference(null, msgs); |
236 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
237 | return ((InternalEList<?>)getOutputParameterInstances()).basicRemove(otherEnd, msgs); |
238 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
239 | return ((InternalEList<?>)getInputParameterInstances()).basicRemove(otherEnd, msgs); |
240 | } |
241 | return super.eInverseRemove(otherEnd, featureID, msgs); |
242 | } |
243 | |
244 | /** |
245 | * <!-- begin-user-doc --> |
246 | * <!-- end-user-doc --> |
247 | * @generated |
248 | */ |
249 | @Override |
250 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
251 | switch (featureID) { |
252 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
253 | return getOperationReference(); |
254 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
255 | return getOutputParameterInstances(); |
256 | case ParametersPackage.CALL_INSTANCE__NUMBER_OF_CALLS: |
257 | return getNumberOfCalls(); |
258 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
259 | return getInputParameterInstances(); |
260 | } |
261 | return super.eGet(featureID, resolve, coreType); |
262 | } |
263 | |
264 | /** |
265 | * <!-- begin-user-doc --> |
266 | * <!-- end-user-doc --> |
267 | * @generated |
268 | */ |
269 | @SuppressWarnings("unchecked") |
270 | @Override |
271 | public void eSet(int featureID, Object newValue) { |
272 | switch (featureID) { |
273 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
274 | setOperationReference((OperationReference)newValue); |
275 | return; |
276 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
277 | getOutputParameterInstances().clear(); |
278 | getOutputParameterInstances().addAll((Collection<? extends ParameterInstance>)newValue); |
279 | return; |
280 | case ParametersPackage.CALL_INSTANCE__NUMBER_OF_CALLS: |
281 | setNumberOfCalls((Long)newValue); |
282 | return; |
283 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
284 | getInputParameterInstances().clear(); |
285 | getInputParameterInstances().addAll((Collection<? extends ParameterInstance>)newValue); |
286 | return; |
287 | } |
288 | super.eSet(featureID, newValue); |
289 | } |
290 | |
291 | /** |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | */ |
296 | @Override |
297 | public void eUnset(int featureID) { |
298 | switch (featureID) { |
299 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
300 | setOperationReference((OperationReference)null); |
301 | return; |
302 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
303 | getOutputParameterInstances().clear(); |
304 | return; |
305 | case ParametersPackage.CALL_INSTANCE__NUMBER_OF_CALLS: |
306 | setNumberOfCalls(NUMBER_OF_CALLS_EDEFAULT); |
307 | return; |
308 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
309 | getInputParameterInstances().clear(); |
310 | return; |
311 | } |
312 | super.eUnset(featureID); |
313 | } |
314 | |
315 | /** |
316 | * <!-- begin-user-doc --> |
317 | * <!-- end-user-doc --> |
318 | * @generated |
319 | */ |
320 | @Override |
321 | public boolean eIsSet(int featureID) { |
322 | switch (featureID) { |
323 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
324 | return operationReference != null; |
325 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
326 | return outputParameterInstances != null && !outputParameterInstances.isEmpty(); |
327 | case ParametersPackage.CALL_INSTANCE__NUMBER_OF_CALLS: |
328 | return numberOfCalls != NUMBER_OF_CALLS_EDEFAULT; |
329 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
330 | return inputParameterInstances != null && !inputParameterInstances.isEmpty(); |
331 | } |
332 | return super.eIsSet(featureID); |
333 | } |
334 | |
335 | /** |
336 | * <!-- begin-user-doc --> |
337 | * <!-- end-user-doc --> |
338 | * @generated |
339 | */ |
340 | @Override |
341 | public String toString() { |
342 | if (eIsProxy()) return super.toString(); |
343 | |
344 | StringBuffer result = new StringBuffer(super.toString()); |
345 | result.append(" (numberOfCalls: "); |
346 | result.append(numberOfCalls); |
347 | result.append(')'); |
348 | return result.toString(); |
349 | } |
350 | |
351 | } //CallInstanceImpl |