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.DimensionTypeSet; |
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 Set</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.DimensionTypeSetImpl#getElements <em>Elements</em>}</li> |
48 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.impl.DimensionTypeSetImpl#getOrder <em>Order</em>}</li> |
49 | * </ul> |
50 | * </p> |
51 | * |
52 | * @generated |
53 | */ |
54 | public class DimensionTypeSetImpl extends DimensionTypeImpl implements DimensionTypeSet { |
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 DimensionTypeSetImpl() { |
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_SET; |
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_SET__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_SET__ORDER); |
114 | } |
115 | return order; |
116 | } |
117 | |
118 | /** |
119 | * The cached OCL expression body for the '{@link #ORDER_can_only_exist_with_RELATIONSEMANTICS(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>ORDER can only exist with RELATIONSEMANTICS</em>}' operation. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @see #ORDER_can_only_exist_with_RELATIONSEMANTICS(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__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.relationSemantics=null implies self.order->size()=0"; |
127 | |
128 | /** |
129 | * The cached OCL invariant for the '{@link #ORDER_can_only_exist_with_RELATIONSEMANTICS(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>ORDER can only exist with RELATIONSEMANTICS</em>}' invariant operation. |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @see #ORDER_can_only_exist_with_RELATIONSEMANTICS(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
133 | * @generated |
134 | * @ordered |
135 | */ |
136 | protected static Constraint ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
137 | |
138 | /** |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | public boolean ORDER_can_only_exist_with_RELATIONSEMANTICS(DiagnosticChain diagnostics, Map<Object, Object> context) { |
144 | if (ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
145 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
146 | helper.setContext(QMLContractTypePackage.Literals.DIMENSION_TYPE_SET); |
147 | try { |
148 | ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
149 | } |
150 | catch (ParserException pe) { |
151 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
152 | } |
153 | } |
154 | if (!EOCL_ENV.createQuery(ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
155 | if (diagnostics != null) { |
156 | diagnostics.add |
157 | (new BasicDiagnostic |
158 | (Diagnostic.ERROR, |
159 | QMLContractTypeValidator.DIAGNOSTIC_SOURCE, |
160 | QMLContractTypeValidator.DIMENSION_TYPE_SET__ORDER_CAN_ONLY_EXIST_WITH_RELATIONSEMANTICS, |
161 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ORDER_can_only_exist_with_RELATIONSEMANTICS", EObjectValidator.getObjectLabel(this, context) }), |
162 | new Object [] { this })); |
163 | } |
164 | return false; |
165 | } |
166 | return true; |
167 | } |
168 | |
169 | /** |
170 | * <!-- begin-user-doc --> |
171 | * <!-- end-user-doc --> |
172 | * @generated |
173 | */ |
174 | @Override |
175 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
176 | switch (featureID) { |
177 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ELEMENTS: |
178 | return ((InternalEList<?>)getElements()).basicRemove(otherEnd, msgs); |
179 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ORDER: |
180 | return ((InternalEList<?>)getOrder()).basicRemove(otherEnd, msgs); |
181 | } |
182 | return super.eInverseRemove(otherEnd, featureID, msgs); |
183 | } |
184 | |
185 | /** |
186 | * <!-- begin-user-doc --> |
187 | * <!-- end-user-doc --> |
188 | * @generated |
189 | */ |
190 | @Override |
191 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
192 | switch (featureID) { |
193 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ELEMENTS: |
194 | return getElements(); |
195 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ORDER: |
196 | return getOrder(); |
197 | } |
198 | return super.eGet(featureID, resolve, coreType); |
199 | } |
200 | |
201 | /** |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @generated |
205 | */ |
206 | @SuppressWarnings("unchecked") |
207 | @Override |
208 | public void eSet(int featureID, Object newValue) { |
209 | switch (featureID) { |
210 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ELEMENTS: |
211 | getElements().clear(); |
212 | getElements().addAll((Collection<? extends Element>)newValue); |
213 | return; |
214 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ORDER: |
215 | getOrder().clear(); |
216 | getOrder().addAll((Collection<? extends Order>)newValue); |
217 | return; |
218 | } |
219 | super.eSet(featureID, newValue); |
220 | } |
221 | |
222 | /** |
223 | * <!-- begin-user-doc --> |
224 | * <!-- end-user-doc --> |
225 | * @generated |
226 | */ |
227 | @Override |
228 | public void eUnset(int featureID) { |
229 | switch (featureID) { |
230 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ELEMENTS: |
231 | getElements().clear(); |
232 | return; |
233 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ORDER: |
234 | getOrder().clear(); |
235 | return; |
236 | } |
237 | super.eUnset(featureID); |
238 | } |
239 | |
240 | /** |
241 | * <!-- begin-user-doc --> |
242 | * <!-- end-user-doc --> |
243 | * @generated |
244 | */ |
245 | @Override |
246 | public boolean eIsSet(int featureID) { |
247 | switch (featureID) { |
248 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ELEMENTS: |
249 | return elements != null && !elements.isEmpty(); |
250 | case QMLContractTypePackage.DIMENSION_TYPE_SET__ORDER: |
251 | return order != null && !order.isEmpty(); |
252 | } |
253 | return super.eIsSet(featureID); |
254 | } |
255 | |
256 | /** |
257 | * The cached environment for evaluating OCL expressions. |
258 | * <!-- begin-user-doc --> |
259 | * <!-- end-user-doc --> |
260 | * @generated |
261 | * @ordered |
262 | */ |
263 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
264 | |
265 | } //DimensionTypeSetImpl |