1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl; |
8 | |
9 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.NumericRange; |
10 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypePackage; |
11 | |
12 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.util.QMLContractTypeValidator; |
13 | |
14 | import de.uka.ipd.sdq.identifier.impl.IdentifierImpl; |
15 | |
16 | import java.util.Map; |
17 | |
18 | import org.eclipse.emf.common.notify.Notification; |
19 | |
20 | import org.eclipse.emf.common.util.BasicDiagnostic; |
21 | import org.eclipse.emf.common.util.Diagnostic; |
22 | import org.eclipse.emf.common.util.DiagnosticChain; |
23 | |
24 | import org.eclipse.emf.ecore.EClass; |
25 | |
26 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
27 | |
28 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
29 | |
30 | import org.eclipse.emf.ecore.util.EObjectValidator; |
31 | |
32 | import org.eclipse.ocl.ParserException; |
33 | |
34 | import org.eclipse.ocl.ecore.Constraint; |
35 | import org.eclipse.ocl.ecore.OCL; |
36 | |
37 | /** |
38 | * <!-- begin-user-doc --> |
39 | * An implementation of the model object '<em><b>Numeric Range</b></em>'. |
40 | * <!-- end-user-doc --> |
41 | * <p> |
42 | * The following features are implemented: |
43 | * <ul> |
44 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.NumericRangeImpl#getLowerLimit <em>Lower Limit</em>}</li> |
45 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.NumericRangeImpl#getUpperLimit <em>Upper Limit</em>}</li> |
46 | * </ul> |
47 | * </p> |
48 | * |
49 | * @generated |
50 | */ |
51 | public class NumericRangeImpl extends IdentifierImpl implements NumericRange { |
52 | /** |
53 | * The default value of the '{@link #getLowerLimit() <em>Lower Limit</em>}' attribute. |
54 | * <!-- begin-user-doc --> |
55 | * <!-- end-user-doc --> |
56 | * @see #getLowerLimit() |
57 | * @generated |
58 | * @ordered |
59 | */ |
60 | protected static final double LOWER_LIMIT_EDEFAULT = 0.0; |
61 | |
62 | /** |
63 | * The cached value of the '{@link #getLowerLimit() <em>Lower Limit</em>}' attribute. |
64 | * <!-- begin-user-doc --> |
65 | * <!-- end-user-doc --> |
66 | * @see #getLowerLimit() |
67 | * @generated |
68 | * @ordered |
69 | */ |
70 | protected double lowerLimit = LOWER_LIMIT_EDEFAULT; |
71 | |
72 | /** |
73 | * The default value of the '{@link #getUpperLimit() <em>Upper Limit</em>}' attribute. |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @see #getUpperLimit() |
77 | * @generated |
78 | * @ordered |
79 | */ |
80 | protected static final double UPPER_LIMIT_EDEFAULT = 0.0; |
81 | |
82 | /** |
83 | * The cached value of the '{@link #getUpperLimit() <em>Upper Limit</em>}' attribute. |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @see #getUpperLimit() |
87 | * @generated |
88 | * @ordered |
89 | */ |
90 | protected double upperLimit = UPPER_LIMIT_EDEFAULT; |
91 | |
92 | /** |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | protected NumericRangeImpl() { |
98 | super(); |
99 | } |
100 | |
101 | /** |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | @Override |
107 | protected EClass eStaticClass() { |
108 | return QMLContractTypePackage.Literals.NUMERIC_RANGE; |
109 | } |
110 | |
111 | /** |
112 | * <!-- begin-user-doc --> |
113 | * <!-- end-user-doc --> |
114 | * @generated |
115 | */ |
116 | public double getLowerLimit() { |
117 | return lowerLimit; |
118 | } |
119 | |
120 | /** |
121 | * <!-- begin-user-doc --> |
122 | * <!-- end-user-doc --> |
123 | * @generated |
124 | */ |
125 | public void setLowerLimit(double newLowerLimit) { |
126 | double oldLowerLimit = lowerLimit; |
127 | lowerLimit = newLowerLimit; |
128 | if (eNotificationRequired()) |
129 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractTypePackage.NUMERIC_RANGE__LOWER_LIMIT, oldLowerLimit, lowerLimit)); |
130 | } |
131 | |
132 | /** |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | public double getUpperLimit() { |
138 | return upperLimit; |
139 | } |
140 | |
141 | /** |
142 | * <!-- begin-user-doc --> |
143 | * <!-- end-user-doc --> |
144 | * @generated |
145 | */ |
146 | public void setUpperLimit(double newUpperLimit) { |
147 | double oldUpperLimit = upperLimit; |
148 | upperLimit = newUpperLimit; |
149 | if (eNotificationRequired()) |
150 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractTypePackage.NUMERIC_RANGE__UPPER_LIMIT, oldUpperLimit, upperLimit)); |
151 | } |
152 | |
153 | /** |
154 | * The cached OCL expression body for the '{@link #UPPERLIMIT_must_be_greater_than_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>UPPERLIMIT must be greater than LOWERLIMIT</em>}' operation. |
155 | * <!-- begin-user-doc --> |
156 | * <!-- end-user-doc --> |
157 | * @see #UPPERLIMIT_must_be_greater_than_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
158 | * @generated |
159 | * @ordered |
160 | */ |
161 | protected static final String UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.upperLimit.oclAsType(Real) > self.lowerLimit.oclAsType(Real)"; |
162 | |
163 | /** |
164 | * The cached OCL invariant for the '{@link #UPPERLIMIT_must_be_greater_than_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>UPPERLIMIT must be greater than LOWERLIMIT</em>}' invariant operation. |
165 | * <!-- begin-user-doc --> |
166 | * <!-- end-user-doc --> |
167 | * @see #UPPERLIMIT_must_be_greater_than_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
168 | * @generated |
169 | * @ordered |
170 | */ |
171 | protected static Constraint UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
172 | |
173 | /** |
174 | * <!-- begin-user-doc --> |
175 | * <!-- end-user-doc --> |
176 | * @generated |
177 | */ |
178 | public boolean UPPERLIMIT_must_be_greater_than_LOWERLIMIT(DiagnosticChain diagnostics, Map<Object, Object> context) { |
179 | if (UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
180 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
181 | helper.setContext(QMLContractTypePackage.Literals.NUMERIC_RANGE); |
182 | try { |
183 | UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
184 | } |
185 | catch (ParserException pe) { |
186 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
187 | } |
188 | } |
189 | if (!EOCL_ENV.createQuery(UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
190 | if (diagnostics != null) { |
191 | diagnostics.add |
192 | (new BasicDiagnostic |
193 | (Diagnostic.ERROR, |
194 | QMLContractTypeValidator.DIAGNOSTIC_SOURCE, |
195 | QMLContractTypeValidator.NUMERIC_RANGE__UPPERLIMIT_MUST_BE_GREATER_THAN_LOWERLIMIT, |
196 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "UPPERLIMIT_must_be_greater_than_LOWERLIMIT", EObjectValidator.getObjectLabel(this, context) }), |
197 | new Object [] { this })); |
198 | } |
199 | return false; |
200 | } |
201 | return true; |
202 | } |
203 | |
204 | /** |
205 | * <!-- begin-user-doc --> |
206 | * <!-- end-user-doc --> |
207 | * @generated |
208 | */ |
209 | @Override |
210 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
211 | switch (featureID) { |
212 | case QMLContractTypePackage.NUMERIC_RANGE__LOWER_LIMIT: |
213 | return getLowerLimit(); |
214 | case QMLContractTypePackage.NUMERIC_RANGE__UPPER_LIMIT: |
215 | return getUpperLimit(); |
216 | } |
217 | return super.eGet(featureID, resolve, coreType); |
218 | } |
219 | |
220 | /** |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | @Override |
226 | public void eSet(int featureID, Object newValue) { |
227 | switch (featureID) { |
228 | case QMLContractTypePackage.NUMERIC_RANGE__LOWER_LIMIT: |
229 | setLowerLimit((Double)newValue); |
230 | return; |
231 | case QMLContractTypePackage.NUMERIC_RANGE__UPPER_LIMIT: |
232 | setUpperLimit((Double)newValue); |
233 | return; |
234 | } |
235 | super.eSet(featureID, newValue); |
236 | } |
237 | |
238 | /** |
239 | * <!-- begin-user-doc --> |
240 | * <!-- end-user-doc --> |
241 | * @generated |
242 | */ |
243 | @Override |
244 | public void eUnset(int featureID) { |
245 | switch (featureID) { |
246 | case QMLContractTypePackage.NUMERIC_RANGE__LOWER_LIMIT: |
247 | setLowerLimit(LOWER_LIMIT_EDEFAULT); |
248 | return; |
249 | case QMLContractTypePackage.NUMERIC_RANGE__UPPER_LIMIT: |
250 | setUpperLimit(UPPER_LIMIT_EDEFAULT); |
251 | return; |
252 | } |
253 | super.eUnset(featureID); |
254 | } |
255 | |
256 | /** |
257 | * <!-- begin-user-doc --> |
258 | * <!-- end-user-doc --> |
259 | * @generated |
260 | */ |
261 | @Override |
262 | public boolean eIsSet(int featureID) { |
263 | switch (featureID) { |
264 | case QMLContractTypePackage.NUMERIC_RANGE__LOWER_LIMIT: |
265 | return lowerLimit != LOWER_LIMIT_EDEFAULT; |
266 | case QMLContractTypePackage.NUMERIC_RANGE__UPPER_LIMIT: |
267 | return upperLimit != UPPER_LIMIT_EDEFAULT; |
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(" (lowerLimit: "); |
283 | result.append(lowerLimit); |
284 | result.append(", upperLimit: "); |
285 | result.append(upperLimit); |
286 | result.append(')'); |
287 | return result.toString(); |
288 | } |
289 | |
290 | /** |
291 | * The cached environment for evaluating OCL expressions. |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | * @ordered |
296 | */ |
297 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
298 | |
299 | } //NumericRangeImpl |