1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.markov.impl; |
8 | |
9 | import de.uka.ipd.sdq.markov.MarkovPackage; |
10 | import de.uka.ipd.sdq.markov.State; |
11 | import de.uka.ipd.sdq.markov.Transition; |
12 | |
13 | import org.eclipse.emf.common.notify.Notification; |
14 | |
15 | import org.eclipse.emf.ecore.EClass; |
16 | import org.eclipse.emf.ecore.InternalEObject; |
17 | |
18 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
19 | |
20 | /** |
21 | * <!-- begin-user-doc --> |
22 | * An implementation of the model object '<em><b>Transition</b></em>'. |
23 | * <!-- end-user-doc --> |
24 | * <p> |
25 | * The following features are implemented: |
26 | * <ul> |
27 | * <li>{@link de.uka.ipd.sdq.markov.impl.TransitionImpl#getProbability <em>Probability</em>}</li> |
28 | * <li>{@link de.uka.ipd.sdq.markov.impl.TransitionImpl#getFromState <em>From State</em>}</li> |
29 | * <li>{@link de.uka.ipd.sdq.markov.impl.TransitionImpl#getToState <em>To State</em>}</li> |
30 | * </ul> |
31 | * </p> |
32 | * |
33 | * @generated |
34 | */ |
35 | public class TransitionImpl extends EntityImpl implements Transition { |
36 | /** |
37 | * The default value of the '{@link #getProbability() <em>Probability</em>}' attribute. |
38 | * <!-- begin-user-doc --> |
39 | * <!-- end-user-doc --> |
40 | * @see #getProbability() |
41 | * @generated |
42 | * @ordered |
43 | */ |
44 | protected static final double PROBABILITY_EDEFAULT = 0.0; |
45 | |
46 | /** |
47 | * The cached value of the '{@link #getProbability() <em>Probability</em>}' attribute. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @see #getProbability() |
51 | * @generated |
52 | * @ordered |
53 | */ |
54 | protected double probability = PROBABILITY_EDEFAULT; |
55 | |
56 | /** |
57 | * The cached value of the '{@link #getFromState() <em>From State</em>}' reference. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @see #getFromState() |
61 | * @generated |
62 | * @ordered |
63 | */ |
64 | protected State fromState; |
65 | |
66 | /** |
67 | * The cached value of the '{@link #getToState() <em>To State</em>}' reference. |
68 | * <!-- begin-user-doc --> |
69 | * <!-- end-user-doc --> |
70 | * @see #getToState() |
71 | * @generated |
72 | * @ordered |
73 | */ |
74 | protected State toState; |
75 | |
76 | /** |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @generated |
80 | */ |
81 | protected TransitionImpl() { |
82 | super(); |
83 | } |
84 | |
85 | /** |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @generated |
89 | */ |
90 | @Override |
91 | protected EClass eStaticClass() { |
92 | return MarkovPackage.Literals.TRANSITION; |
93 | } |
94 | |
95 | /** |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @generated |
99 | */ |
100 | public double getProbability() { |
101 | return probability; |
102 | } |
103 | |
104 | /** |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | public void setProbability(double newProbability) { |
110 | double oldProbability = probability; |
111 | probability = newProbability; |
112 | if (eNotificationRequired()) |
113 | eNotify(new ENotificationImpl(this, Notification.SET, MarkovPackage.TRANSITION__PROBABILITY, oldProbability, probability)); |
114 | } |
115 | |
116 | /** |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | public State getFromState() { |
122 | if (fromState != null && fromState.eIsProxy()) { |
123 | InternalEObject oldFromState = (InternalEObject)fromState; |
124 | fromState = (State)eResolveProxy(oldFromState); |
125 | if (fromState != oldFromState) { |
126 | if (eNotificationRequired()) |
127 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, MarkovPackage.TRANSITION__FROM_STATE, oldFromState, fromState)); |
128 | } |
129 | } |
130 | return fromState; |
131 | } |
132 | |
133 | /** |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | public State basicGetFromState() { |
139 | return fromState; |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | public void setFromState(State newFromState) { |
148 | State oldFromState = fromState; |
149 | fromState = newFromState; |
150 | if (eNotificationRequired()) |
151 | eNotify(new ENotificationImpl(this, Notification.SET, MarkovPackage.TRANSITION__FROM_STATE, oldFromState, fromState)); |
152 | } |
153 | |
154 | /** |
155 | * <!-- begin-user-doc --> |
156 | * <!-- end-user-doc --> |
157 | * @generated |
158 | */ |
159 | public State getToState() { |
160 | if (toState != null && toState.eIsProxy()) { |
161 | InternalEObject oldToState = (InternalEObject)toState; |
162 | toState = (State)eResolveProxy(oldToState); |
163 | if (toState != oldToState) { |
164 | if (eNotificationRequired()) |
165 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, MarkovPackage.TRANSITION__TO_STATE, oldToState, toState)); |
166 | } |
167 | } |
168 | return toState; |
169 | } |
170 | |
171 | /** |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | public State basicGetToState() { |
177 | return toState; |
178 | } |
179 | |
180 | /** |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | public void setToState(State newToState) { |
186 | State oldToState = toState; |
187 | toState = newToState; |
188 | if (eNotificationRequired()) |
189 | eNotify(new ENotificationImpl(this, Notification.SET, MarkovPackage.TRANSITION__TO_STATE, oldToState, toState)); |
190 | } |
191 | |
192 | /** |
193 | * <!-- begin-user-doc --> |
194 | * <!-- end-user-doc --> |
195 | * @generated |
196 | */ |
197 | @Override |
198 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
199 | switch (featureID) { |
200 | case MarkovPackage.TRANSITION__PROBABILITY: |
201 | return getProbability(); |
202 | case MarkovPackage.TRANSITION__FROM_STATE: |
203 | if (resolve) return getFromState(); |
204 | return basicGetFromState(); |
205 | case MarkovPackage.TRANSITION__TO_STATE: |
206 | if (resolve) return getToState(); |
207 | return basicGetToState(); |
208 | } |
209 | return super.eGet(featureID, resolve, coreType); |
210 | } |
211 | |
212 | /** |
213 | * <!-- begin-user-doc --> |
214 | * <!-- end-user-doc --> |
215 | * @generated |
216 | */ |
217 | @Override |
218 | public void eSet(int featureID, Object newValue) { |
219 | switch (featureID) { |
220 | case MarkovPackage.TRANSITION__PROBABILITY: |
221 | setProbability((Double)newValue); |
222 | return; |
223 | case MarkovPackage.TRANSITION__FROM_STATE: |
224 | setFromState((State)newValue); |
225 | return; |
226 | case MarkovPackage.TRANSITION__TO_STATE: |
227 | setToState((State)newValue); |
228 | return; |
229 | } |
230 | super.eSet(featureID, newValue); |
231 | } |
232 | |
233 | /** |
234 | * <!-- begin-user-doc --> |
235 | * <!-- end-user-doc --> |
236 | * @generated |
237 | */ |
238 | @Override |
239 | public void eUnset(int featureID) { |
240 | switch (featureID) { |
241 | case MarkovPackage.TRANSITION__PROBABILITY: |
242 | setProbability(PROBABILITY_EDEFAULT); |
243 | return; |
244 | case MarkovPackage.TRANSITION__FROM_STATE: |
245 | setFromState((State)null); |
246 | return; |
247 | case MarkovPackage.TRANSITION__TO_STATE: |
248 | setToState((State)null); |
249 | return; |
250 | } |
251 | super.eUnset(featureID); |
252 | } |
253 | |
254 | /** |
255 | * <!-- begin-user-doc --> |
256 | * <!-- end-user-doc --> |
257 | * @generated |
258 | */ |
259 | @Override |
260 | public boolean eIsSet(int featureID) { |
261 | switch (featureID) { |
262 | case MarkovPackage.TRANSITION__PROBABILITY: |
263 | return probability != PROBABILITY_EDEFAULT; |
264 | case MarkovPackage.TRANSITION__FROM_STATE: |
265 | return fromState != null; |
266 | case MarkovPackage.TRANSITION__TO_STATE: |
267 | return toState != null; |
268 | } |
269 | return super.eIsSet(featureID); |
270 | } |
271 | |
272 | /** |
273 | * <!-- begin-user-doc --> |
274 | * <!-- end-user-doc --> |
275 | * @generated |
276 | */ |
277 | @Override |
278 | public String toString() { |
279 | if (eIsProxy()) return super.toString(); |
280 | |
281 | StringBuffer result = new StringBuffer(super.toString()); |
282 | result.append(" (probability: "); |
283 | result.append(probability); |
284 | result.append(')'); |
285 | return result.toString(); |
286 | } |
287 | |
288 | } //TransitionImpl |