1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.repository.impl; |
7 | |
8 | import java.util.Collection; |
9 | import java.util.Map; |
10 | |
11 | import org.eclipse.emf.common.notify.Notification; |
12 | import org.eclipse.emf.common.notify.NotificationChain; |
13 | import org.eclipse.emf.common.util.BasicDiagnostic; |
14 | import org.eclipse.emf.common.util.Diagnostic; |
15 | import org.eclipse.emf.common.util.DiagnosticChain; |
16 | import org.eclipse.emf.common.util.EList; |
17 | import org.eclipse.emf.ecore.EClass; |
18 | import org.eclipse.emf.ecore.InternalEObject; |
19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
20 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
21 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
22 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
23 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
24 | import org.eclipse.emf.ecore.util.EObjectValidator; |
25 | import org.eclipse.emf.ecore.util.EcoreUtil; |
26 | import org.eclipse.emf.ecore.util.InternalEList; |
27 | import org.eclipse.ocl.ParserException; |
28 | import org.eclipse.ocl.ecore.Constraint; |
29 | import org.eclipse.ocl.ecore.OCL; |
30 | |
31 | import de.uka.ipd.sdq.pcm.core.entity.impl.EntityImpl; |
32 | import de.uka.ipd.sdq.pcm.protocol.Protocol; |
33 | import de.uka.ipd.sdq.pcm.repository.Interface; |
34 | import de.uka.ipd.sdq.pcm.repository.Repository; |
35 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
36 | import de.uka.ipd.sdq.pcm.repository.RequiredCharacterisation; |
37 | import de.uka.ipd.sdq.pcm.repository.util.RepositoryValidator; |
38 | |
39 | /** |
40 | * <!-- begin-user-doc --> |
41 | * An implementation of the model object '<em><b>Interface</b></em>'. |
42 | * <!-- end-user-doc --> |
43 | * <p> |
44 | * The following features are implemented: |
45 | * <ul> |
46 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.InterfaceImpl#getParentInterfaces__Interface <em>Parent Interfaces Interface</em>}</li> |
47 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.InterfaceImpl#getProtocols__Interface <em>Protocols Interface</em>}</li> |
48 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.InterfaceImpl#getRequiredCharacterisations <em>Required Characterisations</em>}</li> |
49 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.InterfaceImpl#getRepository__Interface <em>Repository Interface</em>}</li> |
50 | * </ul> |
51 | * </p> |
52 | * |
53 | * @generated |
54 | */ |
55 | public abstract class InterfaceImpl extends EntityImpl implements Interface { |
56 | /** |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @generated |
60 | */ |
61 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
62 | |
63 | /** |
64 | * The cached value of the '{@link #getParentInterfaces__Interface() <em>Parent Interfaces Interface</em>}' reference list. |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @see #getParentInterfaces__Interface() |
68 | * @generated |
69 | * @ordered |
70 | */ |
71 | protected EList<Interface> parentInterfaces__Interface; |
72 | |
73 | /** |
74 | * The cached value of the '{@link #getProtocols__Interface() <em>Protocols Interface</em>}' containment reference list. |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @see #getProtocols__Interface() |
78 | * @generated |
79 | * @ordered |
80 | */ |
81 | protected EList<Protocol> protocols__Interface; |
82 | |
83 | /** |
84 | * The cached value of the '{@link #getRequiredCharacterisations() <em>Required Characterisations</em>}' containment reference list. |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @see #getRequiredCharacterisations() |
88 | * @generated |
89 | * @ordered |
90 | */ |
91 | protected EList<RequiredCharacterisation> requiredCharacterisations; |
92 | |
93 | /** |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | protected InterfaceImpl() { |
99 | super(); |
100 | } |
101 | |
102 | /** |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | @Override |
108 | protected EClass eStaticClass() { |
109 | return RepositoryPackage.Literals.INTERFACE; |
110 | } |
111 | |
112 | /** |
113 | * <!-- begin-user-doc --> |
114 | * <!-- end-user-doc --> |
115 | * @generated |
116 | */ |
117 | public EList<Interface> getParentInterfaces__Interface() { |
118 | if (parentInterfaces__Interface == null) { |
119 | parentInterfaces__Interface = new EObjectResolvingEList<Interface>(Interface.class, this, RepositoryPackage.INTERFACE__PARENT_INTERFACES_INTERFACE); |
120 | } |
121 | return parentInterfaces__Interface; |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | public EList<Protocol> getProtocols__Interface() { |
130 | if (protocols__Interface == null) { |
131 | protocols__Interface = new EObjectContainmentEList<Protocol>(Protocol.class, this, RepositoryPackage.INTERFACE__PROTOCOLS_INTERFACE); |
132 | } |
133 | return protocols__Interface; |
134 | } |
135 | |
136 | /** |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | public EList<RequiredCharacterisation> getRequiredCharacterisations() { |
142 | if (requiredCharacterisations == null) { |
143 | requiredCharacterisations = new EObjectContainmentWithInverseEList<RequiredCharacterisation>(RequiredCharacterisation.class, this, RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS, RepositoryPackage.REQUIRED_CHARACTERISATION__INTERFACE_REQUIRED_CHARACTERISATION); |
144 | } |
145 | return requiredCharacterisations; |
146 | } |
147 | |
148 | /** |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | public Repository getRepository__Interface() { |
154 | if (eContainerFeatureID() != RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE) return null; |
155 | return (Repository)eContainer(); |
156 | } |
157 | |
158 | /** |
159 | * <!-- begin-user-doc --> |
160 | * <!-- end-user-doc --> |
161 | * @generated |
162 | */ |
163 | public NotificationChain basicSetRepository__Interface(Repository newRepository__Interface, NotificationChain msgs) { |
164 | msgs = eBasicSetContainer((InternalEObject)newRepository__Interface, RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE, msgs); |
165 | return msgs; |
166 | } |
167 | |
168 | /** |
169 | * <!-- begin-user-doc --> |
170 | * <!-- end-user-doc --> |
171 | * @generated |
172 | */ |
173 | public void setRepository__Interface(Repository newRepository__Interface) { |
174 | if (newRepository__Interface != eInternalContainer() || (eContainerFeatureID() != RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE && newRepository__Interface != null)) { |
175 | if (EcoreUtil.isAncestor(this, newRepository__Interface)) |
176 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
177 | NotificationChain msgs = null; |
178 | if (eInternalContainer() != null) |
179 | msgs = eBasicRemoveFromContainer(msgs); |
180 | if (newRepository__Interface != null) |
181 | msgs = ((InternalEObject)newRepository__Interface).eInverseAdd(this, RepositoryPackage.REPOSITORY__INTERFACES_REPOSITORY, Repository.class, msgs); |
182 | msgs = basicSetRepository__Interface(newRepository__Interface, msgs); |
183 | if (msgs != null) msgs.dispatch(); |
184 | } |
185 | else if (eNotificationRequired()) |
186 | eNotify(new ENotificationImpl(this, Notification.SET, RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE, newRepository__Interface, newRepository__Interface)); |
187 | } |
188 | |
189 | /** |
190 | * The cached OCL expression body for the '{@link #NoProtocolTypeIDUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>No Protocol Type ID Used Twice</em>}' operation. |
191 | * <!-- begin-user-doc --> |
192 | * <!-- end-user-doc --> |
193 | * @see #NoProtocolTypeIDUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
194 | * @generated |
195 | * @ordered |
196 | */ |
197 | protected static final String NO_PROTOCOL_TYPE_ID_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.protocols__Interface->forAll(p1, p2 |\n"+"p1.protocolTypeID <> p2.protocolTypeID)\n"+""; |
198 | |
199 | /** |
200 | * The cached OCL invariant for the '{@link #NoProtocolTypeIDUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>No Protocol Type ID Used Twice</em>}' invariant operation. |
201 | * <!-- begin-user-doc --> |
202 | * <!-- end-user-doc --> |
203 | * @see #NoProtocolTypeIDUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
204 | * @generated |
205 | * @ordered |
206 | */ |
207 | protected static Constraint NO_PROTOCOL_TYPE_ID_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
208 | |
209 | /** |
210 | * <!-- begin-user-doc --> |
211 | * <!-- end-user-doc --> |
212 | * @generated |
213 | */ |
214 | public boolean NoProtocolTypeIDUsedTwice(DiagnosticChain diagnostics, Map<Object, Object> context) { |
215 | if (NO_PROTOCOL_TYPE_ID_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
216 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
217 | helper.setContext(RepositoryPackage.Literals.INTERFACE); |
218 | try { |
219 | NO_PROTOCOL_TYPE_ID_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(NO_PROTOCOL_TYPE_ID_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
220 | } |
221 | catch (ParserException pe) { |
222 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
223 | } |
224 | } |
225 | if (!EOCL_ENV.createQuery(NO_PROTOCOL_TYPE_ID_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
226 | if (diagnostics != null) { |
227 | diagnostics.add |
228 | (new BasicDiagnostic |
229 | (Diagnostic.ERROR, |
230 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
231 | RepositoryValidator.INTERFACE__NO_PROTOCOL_TYPE_ID_USED_TWICE, |
232 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "NoProtocolTypeIDUsedTwice", EObjectValidator.getObjectLabel(this, context) }), |
233 | new Object [] { this })); |
234 | } |
235 | return false; |
236 | } |
237 | return true; |
238 | } |
239 | |
240 | /** |
241 | * <!-- begin-user-doc --> |
242 | * <!-- end-user-doc --> |
243 | * @generated |
244 | */ |
245 | @SuppressWarnings("unchecked") |
246 | @Override |
247 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
248 | switch (featureID) { |
249 | case RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS: |
250 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getRequiredCharacterisations()).basicAdd(otherEnd, msgs); |
251 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
252 | if (eInternalContainer() != null) |
253 | msgs = eBasicRemoveFromContainer(msgs); |
254 | return basicSetRepository__Interface((Repository)otherEnd, msgs); |
255 | } |
256 | return super.eInverseAdd(otherEnd, featureID, msgs); |
257 | } |
258 | |
259 | /** |
260 | * <!-- begin-user-doc --> |
261 | * <!-- end-user-doc --> |
262 | * @generated |
263 | */ |
264 | @Override |
265 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
266 | switch (featureID) { |
267 | case RepositoryPackage.INTERFACE__PROTOCOLS_INTERFACE: |
268 | return ((InternalEList<?>)getProtocols__Interface()).basicRemove(otherEnd, msgs); |
269 | case RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS: |
270 | return ((InternalEList<?>)getRequiredCharacterisations()).basicRemove(otherEnd, msgs); |
271 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
272 | return basicSetRepository__Interface(null, msgs); |
273 | } |
274 | return super.eInverseRemove(otherEnd, featureID, msgs); |
275 | } |
276 | |
277 | /** |
278 | * <!-- begin-user-doc --> |
279 | * <!-- end-user-doc --> |
280 | * @generated |
281 | */ |
282 | @Override |
283 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
284 | switch (eContainerFeatureID()) { |
285 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
286 | return eInternalContainer().eInverseRemove(this, RepositoryPackage.REPOSITORY__INTERFACES_REPOSITORY, Repository.class, msgs); |
287 | } |
288 | return super.eBasicRemoveFromContainerFeature(msgs); |
289 | } |
290 | |
291 | /** |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | */ |
296 | @Override |
297 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
298 | switch (featureID) { |
299 | case RepositoryPackage.INTERFACE__PARENT_INTERFACES_INTERFACE: |
300 | return getParentInterfaces__Interface(); |
301 | case RepositoryPackage.INTERFACE__PROTOCOLS_INTERFACE: |
302 | return getProtocols__Interface(); |
303 | case RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS: |
304 | return getRequiredCharacterisations(); |
305 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
306 | return getRepository__Interface(); |
307 | } |
308 | return super.eGet(featureID, resolve, coreType); |
309 | } |
310 | |
311 | /** |
312 | * <!-- begin-user-doc --> |
313 | * <!-- end-user-doc --> |
314 | * @generated |
315 | */ |
316 | @SuppressWarnings("unchecked") |
317 | @Override |
318 | public void eSet(int featureID, Object newValue) { |
319 | switch (featureID) { |
320 | case RepositoryPackage.INTERFACE__PARENT_INTERFACES_INTERFACE: |
321 | getParentInterfaces__Interface().clear(); |
322 | getParentInterfaces__Interface().addAll((Collection<? extends Interface>)newValue); |
323 | return; |
324 | case RepositoryPackage.INTERFACE__PROTOCOLS_INTERFACE: |
325 | getProtocols__Interface().clear(); |
326 | getProtocols__Interface().addAll((Collection<? extends Protocol>)newValue); |
327 | return; |
328 | case RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS: |
329 | getRequiredCharacterisations().clear(); |
330 | getRequiredCharacterisations().addAll((Collection<? extends RequiredCharacterisation>)newValue); |
331 | return; |
332 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
333 | setRepository__Interface((Repository)newValue); |
334 | return; |
335 | } |
336 | super.eSet(featureID, newValue); |
337 | } |
338 | |
339 | /** |
340 | * <!-- begin-user-doc --> |
341 | * <!-- end-user-doc --> |
342 | * @generated |
343 | */ |
344 | @Override |
345 | public void eUnset(int featureID) { |
346 | switch (featureID) { |
347 | case RepositoryPackage.INTERFACE__PARENT_INTERFACES_INTERFACE: |
348 | getParentInterfaces__Interface().clear(); |
349 | return; |
350 | case RepositoryPackage.INTERFACE__PROTOCOLS_INTERFACE: |
351 | getProtocols__Interface().clear(); |
352 | return; |
353 | case RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS: |
354 | getRequiredCharacterisations().clear(); |
355 | return; |
356 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
357 | setRepository__Interface((Repository)null); |
358 | return; |
359 | } |
360 | super.eUnset(featureID); |
361 | } |
362 | |
363 | /** |
364 | * <!-- begin-user-doc --> |
365 | * <!-- end-user-doc --> |
366 | * @generated |
367 | */ |
368 | @Override |
369 | public boolean eIsSet(int featureID) { |
370 | switch (featureID) { |
371 | case RepositoryPackage.INTERFACE__PARENT_INTERFACES_INTERFACE: |
372 | return parentInterfaces__Interface != null && !parentInterfaces__Interface.isEmpty(); |
373 | case RepositoryPackage.INTERFACE__PROTOCOLS_INTERFACE: |
374 | return protocols__Interface != null && !protocols__Interface.isEmpty(); |
375 | case RepositoryPackage.INTERFACE__REQUIRED_CHARACTERISATIONS: |
376 | return requiredCharacterisations != null && !requiredCharacterisations.isEmpty(); |
377 | case RepositoryPackage.INTERFACE__REPOSITORY_INTERFACE: |
378 | return getRepository__Interface() != null; |
379 | } |
380 | return super.eIsSet(featureID); |
381 | } |
382 | |
383 | /** |
384 | * The cached environment for evaluating OCL expressions. |
385 | * <!-- begin-user-doc --> |
386 | * <!-- end-user-doc --> |
387 | * @generated |
388 | * @ordered |
389 | */ |
390 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
391 | |
392 | } //InterfaceImpl |