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