1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourceenvironment.impl; |
7 | |
8 | import java.util.Collection; |
9 | |
10 | import org.eclipse.emf.common.notify.Notification; |
11 | import org.eclipse.emf.common.notify.NotificationChain; |
12 | import org.eclipse.emf.common.util.EList; |
13 | import org.eclipse.emf.ecore.EClass; |
14 | import org.eclipse.emf.ecore.InternalEObject; |
15 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
16 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
17 | import org.eclipse.emf.ecore.util.EcoreUtil; |
18 | |
19 | import de.uka.ipd.sdq.pcm.core.entity.impl.EntityImpl; |
20 | import de.uka.ipd.sdq.pcm.resourceenvironment.CommunicationLinkResourceSpecification; |
21 | import de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource; |
22 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
23 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceEnvironment; |
24 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
25 | |
26 | /** |
27 | * <!-- begin-user-doc --> |
28 | * An implementation of the model object '<em><b>Linking Resource</b></em>'. |
29 | * <!-- end-user-doc --> |
30 | * <p> |
31 | * The following features are implemented: |
32 | * <ul> |
33 | * <li>{@link de.uka.ipd.sdq.pcm.resourceenvironment.impl.LinkingResourceImpl#getConnectedResourceContainers_LinkingResource <em>Connected Resource Containers Linking Resource</em>}</li> |
34 | * <li>{@link de.uka.ipd.sdq.pcm.resourceenvironment.impl.LinkingResourceImpl#getCommunicationLinkResourceSpecifications_LinkingResource <em>Communication Link Resource Specifications Linking Resource</em>}</li> |
35 | * <li>{@link de.uka.ipd.sdq.pcm.resourceenvironment.impl.LinkingResourceImpl#getResourceEnvironment_LinkingResource <em>Resource Environment Linking Resource</em>}</li> |
36 | * </ul> |
37 | * </p> |
38 | * |
39 | * @generated |
40 | */ |
41 | public class LinkingResourceImpl extends EntityImpl implements LinkingResource { |
42 | /** |
43 | * <!-- begin-user-doc --> |
44 | * <!-- end-user-doc --> |
45 | * @generated |
46 | */ |
47 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
48 | |
49 | /** |
50 | * The cached value of the '{@link #getConnectedResourceContainers_LinkingResource() <em>Connected Resource Containers Linking Resource</em>}' reference list. |
51 | * <!-- begin-user-doc --> |
52 | * <!-- end-user-doc --> |
53 | * @see #getConnectedResourceContainers_LinkingResource() |
54 | * @generated |
55 | * @ordered |
56 | */ |
57 | protected EList<ResourceContainer> connectedResourceContainers_LinkingResource; |
58 | |
59 | /** |
60 | * The cached value of the '{@link #getCommunicationLinkResourceSpecifications_LinkingResource() <em>Communication Link Resource Specifications Linking Resource</em>}' containment reference. |
61 | * <!-- begin-user-doc --> |
62 | * <!-- end-user-doc --> |
63 | * @see #getCommunicationLinkResourceSpecifications_LinkingResource() |
64 | * @generated |
65 | * @ordered |
66 | */ |
67 | protected CommunicationLinkResourceSpecification communicationLinkResourceSpecifications_LinkingResource; |
68 | |
69 | /** |
70 | * <!-- begin-user-doc --> |
71 | * <!-- end-user-doc --> |
72 | * @generated |
73 | */ |
74 | protected LinkingResourceImpl() { |
75 | super(); |
76 | } |
77 | |
78 | /** |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | @Override |
84 | protected EClass eStaticClass() { |
85 | return ResourceenvironmentPackage.Literals.LINKING_RESOURCE; |
86 | } |
87 | |
88 | /** |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @generated |
92 | */ |
93 | public EList<ResourceContainer> getConnectedResourceContainers_LinkingResource() { |
94 | if (connectedResourceContainers_LinkingResource == null) { |
95 | connectedResourceContainers_LinkingResource = new EObjectResolvingEList<ResourceContainer>(ResourceContainer.class, this, ResourceenvironmentPackage.LINKING_RESOURCE__CONNECTED_RESOURCE_CONTAINERS_LINKING_RESOURCE); |
96 | } |
97 | return connectedResourceContainers_LinkingResource; |
98 | } |
99 | |
100 | /** |
101 | * <!-- begin-user-doc --> |
102 | * <!-- end-user-doc --> |
103 | * @generated |
104 | */ |
105 | public CommunicationLinkResourceSpecification getCommunicationLinkResourceSpecifications_LinkingResource() { |
106 | return communicationLinkResourceSpecifications_LinkingResource; |
107 | } |
108 | |
109 | /** |
110 | * <!-- begin-user-doc --> |
111 | * <!-- end-user-doc --> |
112 | * @generated |
113 | */ |
114 | public NotificationChain basicSetCommunicationLinkResourceSpecifications_LinkingResource(CommunicationLinkResourceSpecification newCommunicationLinkResourceSpecifications_LinkingResource, NotificationChain msgs) { |
115 | CommunicationLinkResourceSpecification oldCommunicationLinkResourceSpecifications_LinkingResource = communicationLinkResourceSpecifications_LinkingResource; |
116 | communicationLinkResourceSpecifications_LinkingResource = newCommunicationLinkResourceSpecifications_LinkingResource; |
117 | if (eNotificationRequired()) { |
118 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE, oldCommunicationLinkResourceSpecifications_LinkingResource, newCommunicationLinkResourceSpecifications_LinkingResource); |
119 | if (msgs == null) msgs = notification; else msgs.add(notification); |
120 | } |
121 | return msgs; |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | public void setCommunicationLinkResourceSpecifications_LinkingResource(CommunicationLinkResourceSpecification newCommunicationLinkResourceSpecifications_LinkingResource) { |
130 | if (newCommunicationLinkResourceSpecifications_LinkingResource != communicationLinkResourceSpecifications_LinkingResource) { |
131 | NotificationChain msgs = null; |
132 | if (communicationLinkResourceSpecifications_LinkingResource != null) |
133 | msgs = ((InternalEObject)communicationLinkResourceSpecifications_LinkingResource).eInverseRemove(this, ResourceenvironmentPackage.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__LINKING_RESOURCE_COMMUNICATION_LINK_RESOURCE_SPECIFICATION, CommunicationLinkResourceSpecification.class, msgs); |
134 | if (newCommunicationLinkResourceSpecifications_LinkingResource != null) |
135 | msgs = ((InternalEObject)newCommunicationLinkResourceSpecifications_LinkingResource).eInverseAdd(this, ResourceenvironmentPackage.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__LINKING_RESOURCE_COMMUNICATION_LINK_RESOURCE_SPECIFICATION, CommunicationLinkResourceSpecification.class, msgs); |
136 | msgs = basicSetCommunicationLinkResourceSpecifications_LinkingResource(newCommunicationLinkResourceSpecifications_LinkingResource, msgs); |
137 | if (msgs != null) msgs.dispatch(); |
138 | } |
139 | else if (eNotificationRequired()) |
140 | eNotify(new ENotificationImpl(this, Notification.SET, ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE, newCommunicationLinkResourceSpecifications_LinkingResource, newCommunicationLinkResourceSpecifications_LinkingResource)); |
141 | } |
142 | |
143 | /** |
144 | * <!-- begin-user-doc --> |
145 | * <!-- end-user-doc --> |
146 | * @generated |
147 | */ |
148 | public ResourceEnvironment getResourceEnvironment_LinkingResource() { |
149 | if (eContainerFeatureID() != ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE) return null; |
150 | return (ResourceEnvironment)eContainer(); |
151 | } |
152 | |
153 | /** |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | public NotificationChain basicSetResourceEnvironment_LinkingResource(ResourceEnvironment newResourceEnvironment_LinkingResource, NotificationChain msgs) { |
159 | msgs = eBasicSetContainer((InternalEObject)newResourceEnvironment_LinkingResource, ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE, msgs); |
160 | return msgs; |
161 | } |
162 | |
163 | /** |
164 | * <!-- begin-user-doc --> |
165 | * <!-- end-user-doc --> |
166 | * @generated |
167 | */ |
168 | public void setResourceEnvironment_LinkingResource(ResourceEnvironment newResourceEnvironment_LinkingResource) { |
169 | if (newResourceEnvironment_LinkingResource != eInternalContainer() || (eContainerFeatureID() != ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE && newResourceEnvironment_LinkingResource != null)) { |
170 | if (EcoreUtil.isAncestor(this, newResourceEnvironment_LinkingResource)) |
171 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
172 | NotificationChain msgs = null; |
173 | if (eInternalContainer() != null) |
174 | msgs = eBasicRemoveFromContainer(msgs); |
175 | if (newResourceEnvironment_LinkingResource != null) |
176 | msgs = ((InternalEObject)newResourceEnvironment_LinkingResource).eInverseAdd(this, ResourceenvironmentPackage.RESOURCE_ENVIRONMENT__LINKING_RESOURCES_RESOURCE_ENVIRONMENT, ResourceEnvironment.class, msgs); |
177 | msgs = basicSetResourceEnvironment_LinkingResource(newResourceEnvironment_LinkingResource, msgs); |
178 | if (msgs != null) msgs.dispatch(); |
179 | } |
180 | else if (eNotificationRequired()) |
181 | eNotify(new ENotificationImpl(this, Notification.SET, ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE, newResourceEnvironment_LinkingResource, newResourceEnvironment_LinkingResource)); |
182 | } |
183 | |
184 | /** |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated |
188 | */ |
189 | @Override |
190 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
191 | switch (featureID) { |
192 | case ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE: |
193 | if (communicationLinkResourceSpecifications_LinkingResource != null) |
194 | msgs = ((InternalEObject)communicationLinkResourceSpecifications_LinkingResource).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE, null, msgs); |
195 | return basicSetCommunicationLinkResourceSpecifications_LinkingResource((CommunicationLinkResourceSpecification)otherEnd, msgs); |
196 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
197 | if (eInternalContainer() != null) |
198 | msgs = eBasicRemoveFromContainer(msgs); |
199 | return basicSetResourceEnvironment_LinkingResource((ResourceEnvironment)otherEnd, msgs); |
200 | } |
201 | return super.eInverseAdd(otherEnd, featureID, msgs); |
202 | } |
203 | |
204 | /** |
205 | * <!-- begin-user-doc --> |
206 | * <!-- end-user-doc --> |
207 | * @generated |
208 | */ |
209 | @Override |
210 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
211 | switch (featureID) { |
212 | case ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE: |
213 | return basicSetCommunicationLinkResourceSpecifications_LinkingResource(null, msgs); |
214 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
215 | return basicSetResourceEnvironment_LinkingResource(null, msgs); |
216 | } |
217 | return super.eInverseRemove(otherEnd, featureID, msgs); |
218 | } |
219 | |
220 | /** |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | @Override |
226 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
227 | switch (eContainerFeatureID()) { |
228 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
229 | return eInternalContainer().eInverseRemove(this, ResourceenvironmentPackage.RESOURCE_ENVIRONMENT__LINKING_RESOURCES_RESOURCE_ENVIRONMENT, ResourceEnvironment.class, msgs); |
230 | } |
231 | return super.eBasicRemoveFromContainerFeature(msgs); |
232 | } |
233 | |
234 | /** |
235 | * <!-- begin-user-doc --> |
236 | * <!-- end-user-doc --> |
237 | * @generated |
238 | */ |
239 | @Override |
240 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
241 | switch (featureID) { |
242 | case ResourceenvironmentPackage.LINKING_RESOURCE__CONNECTED_RESOURCE_CONTAINERS_LINKING_RESOURCE: |
243 | return getConnectedResourceContainers_LinkingResource(); |
244 | case ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE: |
245 | return getCommunicationLinkResourceSpecifications_LinkingResource(); |
246 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
247 | return getResourceEnvironment_LinkingResource(); |
248 | } |
249 | return super.eGet(featureID, resolve, coreType); |
250 | } |
251 | |
252 | /** |
253 | * <!-- begin-user-doc --> |
254 | * <!-- end-user-doc --> |
255 | * @generated |
256 | */ |
257 | @SuppressWarnings("unchecked") |
258 | @Override |
259 | public void eSet(int featureID, Object newValue) { |
260 | switch (featureID) { |
261 | case ResourceenvironmentPackage.LINKING_RESOURCE__CONNECTED_RESOURCE_CONTAINERS_LINKING_RESOURCE: |
262 | getConnectedResourceContainers_LinkingResource().clear(); |
263 | getConnectedResourceContainers_LinkingResource().addAll((Collection<? extends ResourceContainer>)newValue); |
264 | return; |
265 | case ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE: |
266 | setCommunicationLinkResourceSpecifications_LinkingResource((CommunicationLinkResourceSpecification)newValue); |
267 | return; |
268 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
269 | setResourceEnvironment_LinkingResource((ResourceEnvironment)newValue); |
270 | return; |
271 | } |
272 | super.eSet(featureID, newValue); |
273 | } |
274 | |
275 | /** |
276 | * <!-- begin-user-doc --> |
277 | * <!-- end-user-doc --> |
278 | * @generated |
279 | */ |
280 | @Override |
281 | public void eUnset(int featureID) { |
282 | switch (featureID) { |
283 | case ResourceenvironmentPackage.LINKING_RESOURCE__CONNECTED_RESOURCE_CONTAINERS_LINKING_RESOURCE: |
284 | getConnectedResourceContainers_LinkingResource().clear(); |
285 | return; |
286 | case ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE: |
287 | setCommunicationLinkResourceSpecifications_LinkingResource((CommunicationLinkResourceSpecification)null); |
288 | return; |
289 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
290 | setResourceEnvironment_LinkingResource((ResourceEnvironment)null); |
291 | return; |
292 | } |
293 | super.eUnset(featureID); |
294 | } |
295 | |
296 | /** |
297 | * <!-- begin-user-doc --> |
298 | * <!-- end-user-doc --> |
299 | * @generated |
300 | */ |
301 | @Override |
302 | public boolean eIsSet(int featureID) { |
303 | switch (featureID) { |
304 | case ResourceenvironmentPackage.LINKING_RESOURCE__CONNECTED_RESOURCE_CONTAINERS_LINKING_RESOURCE: |
305 | return connectedResourceContainers_LinkingResource != null && !connectedResourceContainers_LinkingResource.isEmpty(); |
306 | case ResourceenvironmentPackage.LINKING_RESOURCE__COMMUNICATION_LINK_RESOURCE_SPECIFICATIONS_LINKING_RESOURCE: |
307 | return communicationLinkResourceSpecifications_LinkingResource != null; |
308 | case ResourceenvironmentPackage.LINKING_RESOURCE__RESOURCE_ENVIRONMENT_LINKING_RESOURCE: |
309 | return getResourceEnvironment_LinkingResource() != null; |
310 | } |
311 | return super.eIsSet(featureID); |
312 | } |
313 | |
314 | } //LinkingResourceImpl |