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.Element; |
10 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.Order; |
11 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypePackage; |
12 | |
13 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.util.QMLContractTypeValidator; |
14 | |
15 | import de.uka.ipd.sdq.identifier.impl.IdentifierImpl; |
16 | |
17 | import java.util.Map; |
18 | |
19 | import org.eclipse.emf.common.notify.Notification; |
20 | |
21 | import org.eclipse.emf.common.util.BasicDiagnostic; |
22 | import org.eclipse.emf.common.util.Diagnostic; |
23 | import org.eclipse.emf.common.util.DiagnosticChain; |
24 | |
25 | import org.eclipse.emf.ecore.EClass; |
26 | import org.eclipse.emf.ecore.InternalEObject; |
27 | |
28 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
29 | |
30 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
31 | |
32 | import org.eclipse.emf.ecore.util.EObjectValidator; |
33 | |
34 | import org.eclipse.ocl.ParserException; |
35 | |
36 | import org.eclipse.ocl.ecore.Constraint; |
37 | import org.eclipse.ocl.ecore.OCL; |
38 | |
39 | /** |
40 | * <!-- begin-user-doc --> |
41 | * An implementation of the model object '<em><b>Order</b></em>'. |
42 | * <!-- end-user-doc --> |
43 | * <p> |
44 | * The following features are implemented: |
45 | * <ul> |
46 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.OrderImpl#getBiggerElement <em>Bigger Element</em>}</li> |
47 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.OrderImpl#getSmallerElement <em>Smaller Element</em>}</li> |
48 | * </ul> |
49 | * </p> |
50 | * |
51 | * @generated |
52 | */ |
53 | public class OrderImpl extends IdentifierImpl implements Order { |
54 | /** |
55 | * The cached value of the '{@link #getBiggerElement() <em>Bigger Element</em>}' reference. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @see #getBiggerElement() |
59 | * @generated |
60 | * @ordered |
61 | */ |
62 | protected Element biggerElement; |
63 | |
64 | /** |
65 | * The cached value of the '{@link #getSmallerElement() <em>Smaller Element</em>}' reference. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @see #getSmallerElement() |
69 | * @generated |
70 | * @ordered |
71 | */ |
72 | protected Element smallerElement; |
73 | |
74 | /** |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @generated |
78 | */ |
79 | protected OrderImpl() { |
80 | super(); |
81 | } |
82 | |
83 | /** |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @generated |
87 | */ |
88 | @Override |
89 | protected EClass eStaticClass() { |
90 | return QMLContractTypePackage.Literals.ORDER; |
91 | } |
92 | |
93 | /** |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | public Element getBiggerElement() { |
99 | if (biggerElement != null && biggerElement.eIsProxy()) { |
100 | InternalEObject oldBiggerElement = (InternalEObject)biggerElement; |
101 | biggerElement = (Element)eResolveProxy(oldBiggerElement); |
102 | if (biggerElement != oldBiggerElement) { |
103 | if (eNotificationRequired()) |
104 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QMLContractTypePackage.ORDER__BIGGER_ELEMENT, oldBiggerElement, biggerElement)); |
105 | } |
106 | } |
107 | return biggerElement; |
108 | } |
109 | |
110 | /** |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | public Element basicGetBiggerElement() { |
116 | return biggerElement; |
117 | } |
118 | |
119 | /** |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | public void setBiggerElement(Element newBiggerElement) { |
125 | Element oldBiggerElement = biggerElement; |
126 | biggerElement = newBiggerElement; |
127 | if (eNotificationRequired()) |
128 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractTypePackage.ORDER__BIGGER_ELEMENT, oldBiggerElement, biggerElement)); |
129 | } |
130 | |
131 | /** |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | public Element getSmallerElement() { |
137 | if (smallerElement != null && smallerElement.eIsProxy()) { |
138 | InternalEObject oldSmallerElement = (InternalEObject)smallerElement; |
139 | smallerElement = (Element)eResolveProxy(oldSmallerElement); |
140 | if (smallerElement != oldSmallerElement) { |
141 | if (eNotificationRequired()) |
142 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QMLContractTypePackage.ORDER__SMALLER_ELEMENT, oldSmallerElement, smallerElement)); |
143 | } |
144 | } |
145 | return smallerElement; |
146 | } |
147 | |
148 | /** |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | public Element basicGetSmallerElement() { |
154 | return smallerElement; |
155 | } |
156 | |
157 | /** |
158 | * <!-- begin-user-doc --> |
159 | * <!-- end-user-doc --> |
160 | * @generated |
161 | */ |
162 | public void setSmallerElement(Element newSmallerElement) { |
163 | Element oldSmallerElement = smallerElement; |
164 | smallerElement = newSmallerElement; |
165 | if (eNotificationRequired()) |
166 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractTypePackage.ORDER__SMALLER_ELEMENT, oldSmallerElement, smallerElement)); |
167 | } |
168 | |
169 | /** |
170 | * The cached OCL expression body for the '{@link #BIGGERELEMENT_must_not_be_SMALLELEMENT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>BIGGERELEMENT must not be SMALLELEMENT</em>}' operation. |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @see #BIGGERELEMENT_must_not_be_SMALLELEMENT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
174 | * @generated |
175 | * @ordered |
176 | */ |
177 | protected static final String BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.biggerElement<>self.smallerElement"; |
178 | |
179 | /** |
180 | * The cached OCL invariant for the '{@link #BIGGERELEMENT_must_not_be_SMALLELEMENT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>BIGGERELEMENT must not be SMALLELEMENT</em>}' invariant operation. |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @see #BIGGERELEMENT_must_not_be_SMALLELEMENT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
184 | * @generated |
185 | * @ordered |
186 | */ |
187 | protected static Constraint BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
188 | |
189 | /** |
190 | * <!-- begin-user-doc --> |
191 | * <!-- end-user-doc --> |
192 | * @generated |
193 | */ |
194 | public boolean BIGGERELEMENT_must_not_be_SMALLELEMENT(DiagnosticChain diagnostics, Map<Object, Object> context) { |
195 | if (BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
196 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
197 | helper.setContext(QMLContractTypePackage.Literals.ORDER); |
198 | try { |
199 | BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
200 | } |
201 | catch (ParserException pe) { |
202 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
203 | } |
204 | } |
205 | if (!EOCL_ENV.createQuery(BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
206 | if (diagnostics != null) { |
207 | diagnostics.add |
208 | (new BasicDiagnostic |
209 | (Diagnostic.ERROR, |
210 | QMLContractTypeValidator.DIAGNOSTIC_SOURCE, |
211 | QMLContractTypeValidator.ORDER__BIGGERELEMENT_MUST_NOT_BE_SMALLELEMENT, |
212 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "BIGGERELEMENT_must_not_be_SMALLELEMENT", EObjectValidator.getObjectLabel(this, context) }), |
213 | new Object [] { this })); |
214 | } |
215 | return false; |
216 | } |
217 | return true; |
218 | } |
219 | |
220 | /** |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | @Override |
226 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
227 | switch (featureID) { |
228 | case QMLContractTypePackage.ORDER__BIGGER_ELEMENT: |
229 | if (resolve) return getBiggerElement(); |
230 | return basicGetBiggerElement(); |
231 | case QMLContractTypePackage.ORDER__SMALLER_ELEMENT: |
232 | if (resolve) return getSmallerElement(); |
233 | return basicGetSmallerElement(); |
234 | } |
235 | return super.eGet(featureID, resolve, coreType); |
236 | } |
237 | |
238 | /** |
239 | * <!-- begin-user-doc --> |
240 | * <!-- end-user-doc --> |
241 | * @generated |
242 | */ |
243 | @Override |
244 | public void eSet(int featureID, Object newValue) { |
245 | switch (featureID) { |
246 | case QMLContractTypePackage.ORDER__BIGGER_ELEMENT: |
247 | setBiggerElement((Element)newValue); |
248 | return; |
249 | case QMLContractTypePackage.ORDER__SMALLER_ELEMENT: |
250 | setSmallerElement((Element)newValue); |
251 | return; |
252 | } |
253 | super.eSet(featureID, newValue); |
254 | } |
255 | |
256 | /** |
257 | * <!-- begin-user-doc --> |
258 | * <!-- end-user-doc --> |
259 | * @generated |
260 | */ |
261 | @Override |
262 | public void eUnset(int featureID) { |
263 | switch (featureID) { |
264 | case QMLContractTypePackage.ORDER__BIGGER_ELEMENT: |
265 | setBiggerElement((Element)null); |
266 | return; |
267 | case QMLContractTypePackage.ORDER__SMALLER_ELEMENT: |
268 | setSmallerElement((Element)null); |
269 | return; |
270 | } |
271 | super.eUnset(featureID); |
272 | } |
273 | |
274 | /** |
275 | * <!-- begin-user-doc --> |
276 | * <!-- end-user-doc --> |
277 | * @generated |
278 | */ |
279 | @Override |
280 | public boolean eIsSet(int featureID) { |
281 | switch (featureID) { |
282 | case QMLContractTypePackage.ORDER__BIGGER_ELEMENT: |
283 | return biggerElement != null; |
284 | case QMLContractTypePackage.ORDER__SMALLER_ELEMENT: |
285 | return smallerElement != null; |
286 | } |
287 | return super.eIsSet(featureID); |
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 | } //OrderImpl |