1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.usagemodel.impl; |
7 | |
8 | import org.eclipse.emf.common.notify.Notification; |
9 | import org.eclipse.emf.common.notify.NotificationChain; |
10 | import org.eclipse.emf.ecore.EClass; |
11 | import org.eclipse.emf.ecore.InternalEObject; |
12 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
13 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
14 | import org.eclipse.emf.ecore.util.EcoreUtil; |
15 | |
16 | import de.uka.ipd.sdq.pcm.usagemodel.Branch; |
17 | import de.uka.ipd.sdq.pcm.usagemodel.BranchTransition; |
18 | import de.uka.ipd.sdq.pcm.usagemodel.ScenarioBehaviour; |
19 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
20 | |
21 | /** |
22 | * <!-- begin-user-doc --> |
23 | * An implementation of the model object '<em><b>Branch Transition</b></em>'. |
24 | * <!-- end-user-doc --> |
25 | * <p> |
26 | * The following features are implemented: |
27 | * <ul> |
28 | * <li>{@link de.uka.ipd.sdq.pcm.usagemodel.impl.BranchTransitionImpl#getBranchProbability <em>Branch Probability</em>}</li> |
29 | * <li>{@link de.uka.ipd.sdq.pcm.usagemodel.impl.BranchTransitionImpl#getBranch_BranchTransition <em>Branch Branch Transition</em>}</li> |
30 | * <li>{@link de.uka.ipd.sdq.pcm.usagemodel.impl.BranchTransitionImpl#getBranchedBehaviour_BranchTransition <em>Branched Behaviour Branch Transition</em>}</li> |
31 | * </ul> |
32 | * </p> |
33 | * |
34 | * @generated |
35 | */ |
36 | public class BranchTransitionImpl extends EObjectImpl implements BranchTransition { |
37 | /** |
38 | * <!-- begin-user-doc --> |
39 | * <!-- end-user-doc --> |
40 | * @generated |
41 | */ |
42 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
43 | |
44 | /** |
45 | * The default value of the '{@link #getBranchProbability() <em>Branch Probability</em>}' attribute. |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @see #getBranchProbability() |
49 | * @generated |
50 | * @ordered |
51 | */ |
52 | protected static final double BRANCH_PROBABILITY_EDEFAULT = 0.0; |
53 | |
54 | /** |
55 | * The cached value of the '{@link #getBranchProbability() <em>Branch Probability</em>}' attribute. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @see #getBranchProbability() |
59 | * @generated |
60 | * @ordered |
61 | */ |
62 | protected double branchProbability = BRANCH_PROBABILITY_EDEFAULT; |
63 | |
64 | /** |
65 | * The cached value of the '{@link #getBranchedBehaviour_BranchTransition() <em>Branched Behaviour Branch Transition</em>}' containment reference. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @see #getBranchedBehaviour_BranchTransition() |
69 | * @generated |
70 | * @ordered |
71 | */ |
72 | protected ScenarioBehaviour branchedBehaviour_BranchTransition; |
73 | |
74 | /** |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @generated |
78 | */ |
79 | protected BranchTransitionImpl() { |
80 | super(); |
81 | } |
82 | |
83 | /** |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @generated |
87 | */ |
88 | @Override |
89 | protected EClass eStaticClass() { |
90 | return UsagemodelPackage.Literals.BRANCH_TRANSITION; |
91 | } |
92 | |
93 | /** |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | public double getBranchProbability() { |
99 | return branchProbability; |
100 | } |
101 | |
102 | /** |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | public void setBranchProbability(double newBranchProbability) { |
108 | double oldBranchProbability = branchProbability; |
109 | branchProbability = newBranchProbability; |
110 | if (eNotificationRequired()) |
111 | eNotify(new ENotificationImpl(this, Notification.SET, UsagemodelPackage.BRANCH_TRANSITION__BRANCH_PROBABILITY, oldBranchProbability, branchProbability)); |
112 | } |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | public Branch getBranch_BranchTransition() { |
120 | if (eContainerFeatureID() != UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION) return null; |
121 | return (Branch)eContainer(); |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | public NotificationChain basicSetBranch_BranchTransition(Branch newBranch_BranchTransition, NotificationChain msgs) { |
130 | msgs = eBasicSetContainer((InternalEObject)newBranch_BranchTransition, UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION, msgs); |
131 | return msgs; |
132 | } |
133 | |
134 | /** |
135 | * <!-- begin-user-doc --> |
136 | * <!-- end-user-doc --> |
137 | * @generated |
138 | */ |
139 | public void setBranch_BranchTransition(Branch newBranch_BranchTransition) { |
140 | if (newBranch_BranchTransition != eInternalContainer() || (eContainerFeatureID() != UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION && newBranch_BranchTransition != null)) { |
141 | if (EcoreUtil.isAncestor(this, newBranch_BranchTransition)) |
142 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
143 | NotificationChain msgs = null; |
144 | if (eInternalContainer() != null) |
145 | msgs = eBasicRemoveFromContainer(msgs); |
146 | if (newBranch_BranchTransition != null) |
147 | msgs = ((InternalEObject)newBranch_BranchTransition).eInverseAdd(this, UsagemodelPackage.BRANCH__BRANCH_TRANSITIONS_BRANCH, Branch.class, msgs); |
148 | msgs = basicSetBranch_BranchTransition(newBranch_BranchTransition, msgs); |
149 | if (msgs != null) msgs.dispatch(); |
150 | } |
151 | else if (eNotificationRequired()) |
152 | eNotify(new ENotificationImpl(this, Notification.SET, UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION, newBranch_BranchTransition, newBranch_BranchTransition)); |
153 | } |
154 | |
155 | /** |
156 | * <!-- begin-user-doc --> |
157 | * <!-- end-user-doc --> |
158 | * @generated |
159 | */ |
160 | public ScenarioBehaviour getBranchedBehaviour_BranchTransition() { |
161 | return branchedBehaviour_BranchTransition; |
162 | } |
163 | |
164 | /** |
165 | * <!-- begin-user-doc --> |
166 | * <!-- end-user-doc --> |
167 | * @generated |
168 | */ |
169 | public NotificationChain basicSetBranchedBehaviour_BranchTransition(ScenarioBehaviour newBranchedBehaviour_BranchTransition, NotificationChain msgs) { |
170 | ScenarioBehaviour oldBranchedBehaviour_BranchTransition = branchedBehaviour_BranchTransition; |
171 | branchedBehaviour_BranchTransition = newBranchedBehaviour_BranchTransition; |
172 | if (eNotificationRequired()) { |
173 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION, oldBranchedBehaviour_BranchTransition, newBranchedBehaviour_BranchTransition); |
174 | if (msgs == null) msgs = notification; else msgs.add(notification); |
175 | } |
176 | return msgs; |
177 | } |
178 | |
179 | /** |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | public void setBranchedBehaviour_BranchTransition(ScenarioBehaviour newBranchedBehaviour_BranchTransition) { |
185 | if (newBranchedBehaviour_BranchTransition != branchedBehaviour_BranchTransition) { |
186 | NotificationChain msgs = null; |
187 | if (branchedBehaviour_BranchTransition != null) |
188 | msgs = ((InternalEObject)branchedBehaviour_BranchTransition).eInverseRemove(this, UsagemodelPackage.SCENARIO_BEHAVIOUR__BRANCH_TRANSITION_SCENARIO_BEHAVIOUR, ScenarioBehaviour.class, msgs); |
189 | if (newBranchedBehaviour_BranchTransition != null) |
190 | msgs = ((InternalEObject)newBranchedBehaviour_BranchTransition).eInverseAdd(this, UsagemodelPackage.SCENARIO_BEHAVIOUR__BRANCH_TRANSITION_SCENARIO_BEHAVIOUR, ScenarioBehaviour.class, msgs); |
191 | msgs = basicSetBranchedBehaviour_BranchTransition(newBranchedBehaviour_BranchTransition, msgs); |
192 | if (msgs != null) msgs.dispatch(); |
193 | } |
194 | else if (eNotificationRequired()) |
195 | eNotify(new ENotificationImpl(this, Notification.SET, UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION, newBranchedBehaviour_BranchTransition, newBranchedBehaviour_BranchTransition)); |
196 | } |
197 | |
198 | /** |
199 | * <!-- begin-user-doc --> |
200 | * <!-- end-user-doc --> |
201 | * @generated |
202 | */ |
203 | @Override |
204 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
205 | switch (featureID) { |
206 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
207 | if (eInternalContainer() != null) |
208 | msgs = eBasicRemoveFromContainer(msgs); |
209 | return basicSetBranch_BranchTransition((Branch)otherEnd, msgs); |
210 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
211 | if (branchedBehaviour_BranchTransition != null) |
212 | msgs = ((InternalEObject)branchedBehaviour_BranchTransition).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION, null, msgs); |
213 | return basicSetBranchedBehaviour_BranchTransition((ScenarioBehaviour)otherEnd, msgs); |
214 | } |
215 | return super.eInverseAdd(otherEnd, featureID, msgs); |
216 | } |
217 | |
218 | /** |
219 | * <!-- begin-user-doc --> |
220 | * <!-- end-user-doc --> |
221 | * @generated |
222 | */ |
223 | @Override |
224 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
225 | switch (featureID) { |
226 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
227 | return basicSetBranch_BranchTransition(null, msgs); |
228 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
229 | return basicSetBranchedBehaviour_BranchTransition(null, msgs); |
230 | } |
231 | return super.eInverseRemove(otherEnd, featureID, msgs); |
232 | } |
233 | |
234 | /** |
235 | * <!-- begin-user-doc --> |
236 | * <!-- end-user-doc --> |
237 | * @generated |
238 | */ |
239 | @Override |
240 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
241 | switch (eContainerFeatureID()) { |
242 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
243 | return eInternalContainer().eInverseRemove(this, UsagemodelPackage.BRANCH__BRANCH_TRANSITIONS_BRANCH, Branch.class, msgs); |
244 | } |
245 | return super.eBasicRemoveFromContainerFeature(msgs); |
246 | } |
247 | |
248 | /** |
249 | * <!-- begin-user-doc --> |
250 | * <!-- end-user-doc --> |
251 | * @generated |
252 | */ |
253 | @Override |
254 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
255 | switch (featureID) { |
256 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_PROBABILITY: |
257 | return getBranchProbability(); |
258 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
259 | return getBranch_BranchTransition(); |
260 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
261 | return getBranchedBehaviour_BranchTransition(); |
262 | } |
263 | return super.eGet(featureID, resolve, coreType); |
264 | } |
265 | |
266 | /** |
267 | * <!-- begin-user-doc --> |
268 | * <!-- end-user-doc --> |
269 | * @generated |
270 | */ |
271 | @Override |
272 | public void eSet(int featureID, Object newValue) { |
273 | switch (featureID) { |
274 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_PROBABILITY: |
275 | setBranchProbability((Double)newValue); |
276 | return; |
277 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
278 | setBranch_BranchTransition((Branch)newValue); |
279 | return; |
280 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
281 | setBranchedBehaviour_BranchTransition((ScenarioBehaviour)newValue); |
282 | return; |
283 | } |
284 | super.eSet(featureID, newValue); |
285 | } |
286 | |
287 | /** |
288 | * <!-- begin-user-doc --> |
289 | * <!-- end-user-doc --> |
290 | * @generated |
291 | */ |
292 | @Override |
293 | public void eUnset(int featureID) { |
294 | switch (featureID) { |
295 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_PROBABILITY: |
296 | setBranchProbability(BRANCH_PROBABILITY_EDEFAULT); |
297 | return; |
298 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
299 | setBranch_BranchTransition((Branch)null); |
300 | return; |
301 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
302 | setBranchedBehaviour_BranchTransition((ScenarioBehaviour)null); |
303 | return; |
304 | } |
305 | super.eUnset(featureID); |
306 | } |
307 | |
308 | /** |
309 | * <!-- begin-user-doc --> |
310 | * <!-- end-user-doc --> |
311 | * @generated |
312 | */ |
313 | @Override |
314 | public boolean eIsSet(int featureID) { |
315 | switch (featureID) { |
316 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_PROBABILITY: |
317 | return branchProbability != BRANCH_PROBABILITY_EDEFAULT; |
318 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCH_BRANCH_TRANSITION: |
319 | return getBranch_BranchTransition() != null; |
320 | case UsagemodelPackage.BRANCH_TRANSITION__BRANCHED_BEHAVIOUR_BRANCH_TRANSITION: |
321 | return branchedBehaviour_BranchTransition != null; |
322 | } |
323 | return super.eIsSet(featureID); |
324 | } |
325 | |
326 | /** |
327 | * <!-- begin-user-doc --> |
328 | * <!-- end-user-doc --> |
329 | * @generated |
330 | */ |
331 | @Override |
332 | public String toString() { |
333 | if (eIsProxy()) return super.toString(); |
334 | |
335 | StringBuffer result = new StringBuffer(super.toString()); |
336 | result.append(" (branchProbability: "); |
337 | result.append(branchProbability); |
338 | result.append(')'); |
339 | return result.toString(); |
340 | } |
341 | |
342 | } //BranchTransitionImpl |