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.DimensionTypeEnum; |
10 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.Element; |
11 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.Order; |
12 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypePackage; |
13 | |
14 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.util.QMLContractTypeValidator; |
15 | |
16 | import java.util.Collection; |
17 | import java.util.Map; |
18 | |
19 | import org.eclipse.emf.common.notify.NotificationChain; |
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 | import org.eclipse.emf.common.util.EList; |
25 | |
26 | import org.eclipse.emf.ecore.EClass; |
27 | import org.eclipse.emf.ecore.InternalEObject; |
28 | |
29 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
30 | |
31 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
32 | import org.eclipse.emf.ecore.util.EObjectValidator; |
33 | import org.eclipse.emf.ecore.util.InternalEList; |
34 | |
35 | import org.eclipse.ocl.ParserException; |
36 | |
37 | import org.eclipse.ocl.ecore.Constraint; |
38 | import org.eclipse.ocl.ecore.OCL; |
39 | |
40 | /** |
41 | * <!-- begin-user-doc --> |
42 | * An implementation of the model object '<em><b>Dimension Type Enum</b></em>'. |
43 | * <!-- end-user-doc --> |
44 | * <p> |
45 | * The following features are implemented: |
46 | * <ul> |
47 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.DimensionTypeEnumImpl#getElements <em>Elements</em>}</li> |
48 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.DimensionTypeEnumImpl#getOrder <em>Order</em>}</li> |
49 | * </ul> |
50 | * </p> |
51 | * |
52 | * @generated |
53 | */ |
54 | public class DimensionTypeEnumImpl extends DimensionTypeImpl implements DimensionTypeEnum { |
55 | /** |
56 | * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @see #getElements() |
60 | * @generated |
61 | * @ordered |
62 | */ |
63 | protected EList<Element> elements; |
64 | |
65 | /** |
66 | * The cached value of the '{@link #getOrder() <em>Order</em>}' containment reference list. |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @see #getOrder() |
70 | * @generated |
71 | * @ordered |
72 | */ |
73 | protected EList<Order> order; |
74 | |
75 | /** |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @generated |
79 | */ |
80 | protected DimensionTypeEnumImpl() { |
81 | super(); |
82 | } |
83 | |
84 | /** |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @generated |
88 | */ |
89 | @Override |
90 | protected EClass eStaticClass() { |
91 | return QMLContractTypePackage.Literals.DIMENSION_TYPE_ENUM; |
92 | } |
93 | |
94 | /** |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @generated |
98 | */ |
99 | public EList<Element> getElements() { |
100 | if (elements == null) { |
101 | elements = new EObjectContainmentEList<Element>(Element.class, this, QMLContractTypePackage.DIMENSION_TYPE_ENUM__ELEMENTS); |
102 | } |
103 | return elements; |
104 | } |
105 | |
106 | /** |
107 | * <!-- begin-user-doc --> |
108 | * <!-- end-user-doc --> |
109 | * @generated |
110 | */ |
111 | public EList<Order> getOrder() { |
112 | if (order == null) { |
113 | order = new EObjectContainmentEList<Order>(Order.class, this, QMLContractTypePackage.DIMENSION_TYPE_ENUM__ORDER); |
114 | } |
115 | return order; |
116 | } |
117 | |
118 | /** |
119 | * The cached OCL expression body for the '{@link #ORDER_can_only_exist_with_RELATIONSEMANTICS_and_vice_versa(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>ORDER can only exist with RELATIONSEMANTICS and vice versa</em>}' operation. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @see #ORDER_can_only_exist_with_RELATIONSEMANTICS_and_vice_versa(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
123 | * @generated |
124 | * @ordered |
125 | */ |
126 | protected static final String ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "(self.relationSemantics=null implies self.order->size()=0) and "+ |
127 | "(self.order->size()=0 implies self.relationSemantics=null)"; |
128 | |
129 | /** |
130 | * The cached OCL invariant for the '{@link #ORDER_can_only_exist_with_RELATIONSEMANTICS_and_vice_versa(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>ORDER can only exist with RELATIONSEMANTICS and vice versa</em>}' invariant operation. |
131 | * <!-- begin-user-doc --> |
132 | * <!-- end-user-doc --> |
133 | * @see #ORDER_can_only_exist_with_RELATIONSEMANTICS_and_vice_versa(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
134 | * @generated |
135 | * @ordered |
136 | */ |
137 | protected static Constraint ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
138 | |
139 | /** |
140 | * <!-- begin-user-doc --> |
141 | * <!-- end-user-doc --> |
142 | * @generated |
143 | */ |
144 | public boolean ORDER_can_only_exist_with_RELATIONSEMANTICS_and_vice_versa(DiagnosticChain diagnostics, Map<Object, Object> context) { |
145 | if (ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
146 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
147 | helper.setContext(QMLContractTypePackage.Literals.DIMENSION_TYPE_ENUM); |
148 | try { |
149 | ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
150 | } |
151 | catch (ParserException pe) { |
152 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
153 | } |
154 | } |
155 | if (!EOCL_ENV.createQuery(ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
156 | if (diagnostics != null) { |
157 | diagnostics.add |
158 | (new BasicDiagnostic |
159 | (Diagnostic.ERROR, |
160 | QMLContractTypeValidator.DIAGNOSTIC_SOURCE, |
161 | QMLContractTypeValidator.DIMENSION_TYPE_ENUM__ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS_AND_VICE_VERSA, |
162 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ORDER_can_only_exist_with_RELATIONSEMANTICS_and_vice_versa", EObjectValidator.getObjectLabel(this, context) }), |
163 | new Object [] { this })); |
164 | } |
165 | return false; |
166 | } |
167 | return true; |
168 | } |
169 | |
170 | /** |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @generated |
174 | */ |
175 | @Override |
176 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
177 | switch (featureID) { |
178 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ELEMENTS: |
179 | return ((InternalEList<?>)getElements()).basicRemove(otherEnd, msgs); |
180 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ORDER: |
181 | return ((InternalEList<?>)getOrder()).basicRemove(otherEnd, msgs); |
182 | } |
183 | return super.eInverseRemove(otherEnd, featureID, msgs); |
184 | } |
185 | |
186 | /** |
187 | * <!-- begin-user-doc --> |
188 | * <!-- end-user-doc --> |
189 | * @generated |
190 | */ |
191 | @Override |
192 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
193 | switch (featureID) { |
194 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ELEMENTS: |
195 | return getElements(); |
196 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ORDER: |
197 | return getOrder(); |
198 | } |
199 | return super.eGet(featureID, resolve, coreType); |
200 | } |
201 | |
202 | /** |
203 | * <!-- begin-user-doc --> |
204 | * <!-- end-user-doc --> |
205 | * @generated |
206 | */ |
207 | @SuppressWarnings("unchecked") |
208 | @Override |
209 | public void eSet(int featureID, Object newValue) { |
210 | switch (featureID) { |
211 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ELEMENTS: |
212 | getElements().clear(); |
213 | getElements().addAll((Collection<? extends Element>)newValue); |
214 | return; |
215 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ORDER: |
216 | getOrder().clear(); |
217 | getOrder().addAll((Collection<? extends Order>)newValue); |
218 | return; |
219 | } |
220 | super.eSet(featureID, newValue); |
221 | } |
222 | |
223 | /** |
224 | * <!-- begin-user-doc --> |
225 | * <!-- end-user-doc --> |
226 | * @generated |
227 | */ |
228 | @Override |
229 | public void eUnset(int featureID) { |
230 | switch (featureID) { |
231 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ELEMENTS: |
232 | getElements().clear(); |
233 | return; |
234 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ORDER: |
235 | getOrder().clear(); |
236 | return; |
237 | } |
238 | super.eUnset(featureID); |
239 | } |
240 | |
241 | /** |
242 | * <!-- begin-user-doc --> |
243 | * <!-- end-user-doc --> |
244 | * @generated |
245 | */ |
246 | @Override |
247 | public boolean eIsSet(int featureID) { |
248 | switch (featureID) { |
249 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ELEMENTS: |
250 | return elements != null && !elements.isEmpty(); |
251 | case QMLContractTypePackage.DIMENSION_TYPE_ENUM__ORDER: |
252 | return order != null && !order.isEmpty(); |
253 | } |
254 | return super.eIsSet(featureID); |
255 | } |
256 | |
257 | /** |
258 | * The cached environment for evaluating OCL expressions. |
259 | * <!-- begin-user-doc --> |
260 | * <!-- end-user-doc --> |
261 | * @generated |
262 | * @ordered |
263 | */ |
264 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
265 | |
266 | } //DimensionTypeEnumImpl |