1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourcetype.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.EObjectContainmentWithInverseEList; |
17 | import org.eclipse.emf.ecore.util.EcoreUtil; |
18 | import org.eclipse.emf.ecore.util.InternalEList; |
19 | |
20 | import de.uka.ipd.sdq.pcm.core.entity.EntityPackage; |
21 | import de.uka.ipd.sdq.pcm.core.entity.ResourceInterfaceProvidingEntity; |
22 | import de.uka.ipd.sdq.pcm.core.entity.ResourceProvidedRole; |
23 | import de.uka.ipd.sdq.pcm.core.entity.impl.EntityImpl; |
24 | import de.uka.ipd.sdq.pcm.resourcetype.ResourceRepository; |
25 | import de.uka.ipd.sdq.pcm.resourcetype.ResourceType; |
26 | import de.uka.ipd.sdq.pcm.resourcetype.ResourcetypePackage; |
27 | import de.uka.ipd.sdq.units.Unit; |
28 | import de.uka.ipd.sdq.units.UnitCarryingElement; |
29 | import de.uka.ipd.sdq.units.UnitsPackage; |
30 | |
31 | /** |
32 | * <!-- begin-user-doc --> |
33 | * An implementation of the model object '<em><b>Resource Type</b></em>'. |
34 | * <!-- end-user-doc --> |
35 | * <p> |
36 | * The following features are implemented: |
37 | * <ul> |
38 | * <li>{@link de.uka.ipd.sdq.pcm.resourcetype.impl.ResourceTypeImpl#getUnit <em>Unit</em>}</li> |
39 | * <li>{@link de.uka.ipd.sdq.pcm.resourcetype.impl.ResourceTypeImpl#getUnitSpecification <em>Unit Specification</em>}</li> |
40 | * <li>{@link de.uka.ipd.sdq.pcm.resourcetype.impl.ResourceTypeImpl#getResourceProvidedRoles__ResourceInterfaceProvidingEntity <em>Resource Provided Roles Resource Interface Providing Entity</em>}</li> |
41 | * <li>{@link de.uka.ipd.sdq.pcm.resourcetype.impl.ResourceTypeImpl#getResourceRepository_ResourceType <em>Resource Repository Resource Type</em>}</li> |
42 | * </ul> |
43 | * </p> |
44 | * |
45 | * @generated |
46 | */ |
47 | public abstract class ResourceTypeImpl extends EntityImpl implements ResourceType { |
48 | /** |
49 | * <!-- begin-user-doc --> |
50 | * <!-- end-user-doc --> |
51 | * @generated |
52 | */ |
53 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
54 | |
55 | /** |
56 | * The default value of the '{@link #getUnitSpecification() <em>Unit Specification</em>}' attribute. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @see #getUnitSpecification() |
60 | * @generated |
61 | * @ordered |
62 | */ |
63 | protected static final String UNIT_SPECIFICATION_EDEFAULT = null; |
64 | |
65 | /** |
66 | * The cached value of the '{@link #getUnitSpecification() <em>Unit Specification</em>}' attribute. |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @see #getUnitSpecification() |
70 | * @generated |
71 | * @ordered |
72 | */ |
73 | protected String unitSpecification = UNIT_SPECIFICATION_EDEFAULT; |
74 | |
75 | /** |
76 | * The cached value of the '{@link #getResourceProvidedRoles__ResourceInterfaceProvidingEntity() <em>Resource Provided Roles Resource Interface Providing Entity</em>}' containment reference list. |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @see #getResourceProvidedRoles__ResourceInterfaceProvidingEntity() |
80 | * @generated |
81 | * @ordered |
82 | */ |
83 | protected EList<ResourceProvidedRole> resourceProvidedRoles__ResourceInterfaceProvidingEntity; |
84 | |
85 | /** |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @generated |
89 | */ |
90 | protected ResourceTypeImpl() { |
91 | super(); |
92 | } |
93 | |
94 | /** |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @generated |
98 | */ |
99 | @Override |
100 | protected EClass eStaticClass() { |
101 | return ResourcetypePackage.Literals.RESOURCE_TYPE; |
102 | } |
103 | |
104 | /** |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | public Unit getUnit() { |
110 | Unit unit = basicGetUnit(); |
111 | return unit != null && unit.eIsProxy() ? (Unit)eResolveProxy((InternalEObject)unit) : unit; |
112 | } |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated not |
118 | */ |
119 | public Unit basicGetUnit() { |
120 | // TODO: implement this method to return the 'Unit' reference |
121 | // -> do not perform proxy resolution |
122 | // Ensure that you remove @generated or mark it @generated NOT |
123 | //throw new UnsupportedOperationException(); |
124 | return null; |
125 | } |
126 | |
127 | /** |
128 | * <!-- begin-user-doc --> |
129 | * <!-- end-user-doc --> |
130 | * @generated not |
131 | */ |
132 | public void setUnit(Unit newUnit) { |
133 | // TODO: implement this method to set the 'Unit' reference |
134 | // Ensure that you remove @generated or mark it @generated NOT |
135 | //throw new UnsupportedOperationException(); |
136 | } |
137 | |
138 | /** |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | public String getUnitSpecification() { |
144 | return unitSpecification; |
145 | } |
146 | |
147 | /** |
148 | * <!-- begin-user-doc --> |
149 | * <!-- end-user-doc --> |
150 | * @generated |
151 | */ |
152 | public void setUnitSpecification(String newUnitSpecification) { |
153 | String oldUnitSpecification = unitSpecification; |
154 | unitSpecification = newUnitSpecification; |
155 | if (eNotificationRequired()) |
156 | eNotify(new ENotificationImpl(this, Notification.SET, ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION, oldUnitSpecification, unitSpecification)); |
157 | } |
158 | |
159 | /** |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | public EList<ResourceProvidedRole> getResourceProvidedRoles__ResourceInterfaceProvidingEntity() { |
165 | if (resourceProvidedRoles__ResourceInterfaceProvidingEntity == null) { |
166 | resourceProvidedRoles__ResourceInterfaceProvidingEntity = new EObjectContainmentWithInverseEList<ResourceProvidedRole>(ResourceProvidedRole.class, this, ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY, EntityPackage.RESOURCE_PROVIDED_ROLE__RESOURCE_INTERFACE_PROVIDING_ENTITY_RESOURCE_PROVIDED_ROLE); |
167 | } |
168 | return resourceProvidedRoles__ResourceInterfaceProvidingEntity; |
169 | } |
170 | |
171 | /** |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | public ResourceRepository getResourceRepository_ResourceType() { |
177 | if (eContainerFeatureID() != ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE) return null; |
178 | return (ResourceRepository)eContainer(); |
179 | } |
180 | |
181 | /** |
182 | * <!-- begin-user-doc --> |
183 | * <!-- end-user-doc --> |
184 | * @generated |
185 | */ |
186 | public NotificationChain basicSetResourceRepository_ResourceType(ResourceRepository newResourceRepository_ResourceType, NotificationChain msgs) { |
187 | msgs = eBasicSetContainer((InternalEObject)newResourceRepository_ResourceType, ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE, msgs); |
188 | return msgs; |
189 | } |
190 | |
191 | /** |
192 | * <!-- begin-user-doc --> |
193 | * <!-- end-user-doc --> |
194 | * @generated |
195 | */ |
196 | public void setResourceRepository_ResourceType(ResourceRepository newResourceRepository_ResourceType) { |
197 | if (newResourceRepository_ResourceType != eInternalContainer() || (eContainerFeatureID() != ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE && newResourceRepository_ResourceType != null)) { |
198 | if (EcoreUtil.isAncestor(this, newResourceRepository_ResourceType)) |
199 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
200 | NotificationChain msgs = null; |
201 | if (eInternalContainer() != null) |
202 | msgs = eBasicRemoveFromContainer(msgs); |
203 | if (newResourceRepository_ResourceType != null) |
204 | msgs = ((InternalEObject)newResourceRepository_ResourceType).eInverseAdd(this, ResourcetypePackage.RESOURCE_REPOSITORY__AVAILABLE_RESOURCE_TYPES_RESOURCE_REPOSITORY, ResourceRepository.class, msgs); |
205 | msgs = basicSetResourceRepository_ResourceType(newResourceRepository_ResourceType, msgs); |
206 | if (msgs != null) msgs.dispatch(); |
207 | } |
208 | else if (eNotificationRequired()) |
209 | eNotify(new ENotificationImpl(this, Notification.SET, ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE, newResourceRepository_ResourceType, newResourceRepository_ResourceType)); |
210 | } |
211 | |
212 | /** |
213 | * <!-- begin-user-doc --> |
214 | * <!-- end-user-doc --> |
215 | * @generated |
216 | */ |
217 | @SuppressWarnings("unchecked") |
218 | @Override |
219 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
220 | switch (featureID) { |
221 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
222 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getResourceProvidedRoles__ResourceInterfaceProvidingEntity()).basicAdd(otherEnd, msgs); |
223 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
224 | if (eInternalContainer() != null) |
225 | msgs = eBasicRemoveFromContainer(msgs); |
226 | return basicSetResourceRepository_ResourceType((ResourceRepository)otherEnd, msgs); |
227 | } |
228 | return super.eInverseAdd(otherEnd, featureID, msgs); |
229 | } |
230 | |
231 | /** |
232 | * <!-- begin-user-doc --> |
233 | * <!-- end-user-doc --> |
234 | * @generated |
235 | */ |
236 | @Override |
237 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
238 | switch (featureID) { |
239 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
240 | return ((InternalEList<?>)getResourceProvidedRoles__ResourceInterfaceProvidingEntity()).basicRemove(otherEnd, msgs); |
241 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
242 | return basicSetResourceRepository_ResourceType(null, msgs); |
243 | } |
244 | return super.eInverseRemove(otherEnd, featureID, msgs); |
245 | } |
246 | |
247 | /** |
248 | * <!-- begin-user-doc --> |
249 | * <!-- end-user-doc --> |
250 | * @generated |
251 | */ |
252 | @Override |
253 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
254 | switch (eContainerFeatureID()) { |
255 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
256 | return eInternalContainer().eInverseRemove(this, ResourcetypePackage.RESOURCE_REPOSITORY__AVAILABLE_RESOURCE_TYPES_RESOURCE_REPOSITORY, ResourceRepository.class, msgs); |
257 | } |
258 | return super.eBasicRemoveFromContainerFeature(msgs); |
259 | } |
260 | |
261 | /** |
262 | * <!-- begin-user-doc --> |
263 | * <!-- end-user-doc --> |
264 | * @generated |
265 | */ |
266 | @Override |
267 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
268 | switch (featureID) { |
269 | case ResourcetypePackage.RESOURCE_TYPE__UNIT: |
270 | if (resolve) return getUnit(); |
271 | return basicGetUnit(); |
272 | case ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION: |
273 | return getUnitSpecification(); |
274 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
275 | return getResourceProvidedRoles__ResourceInterfaceProvidingEntity(); |
276 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
277 | return getResourceRepository_ResourceType(); |
278 | } |
279 | return super.eGet(featureID, resolve, coreType); |
280 | } |
281 | |
282 | /** |
283 | * <!-- begin-user-doc --> |
284 | * <!-- end-user-doc --> |
285 | * @generated |
286 | */ |
287 | @SuppressWarnings("unchecked") |
288 | @Override |
289 | public void eSet(int featureID, Object newValue) { |
290 | switch (featureID) { |
291 | case ResourcetypePackage.RESOURCE_TYPE__UNIT: |
292 | setUnit((Unit)newValue); |
293 | return; |
294 | case ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION: |
295 | setUnitSpecification((String)newValue); |
296 | return; |
297 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
298 | getResourceProvidedRoles__ResourceInterfaceProvidingEntity().clear(); |
299 | getResourceProvidedRoles__ResourceInterfaceProvidingEntity().addAll((Collection<? extends ResourceProvidedRole>)newValue); |
300 | return; |
301 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
302 | setResourceRepository_ResourceType((ResourceRepository)newValue); |
303 | return; |
304 | } |
305 | super.eSet(featureID, newValue); |
306 | } |
307 | |
308 | /** |
309 | * <!-- begin-user-doc --> |
310 | * <!-- end-user-doc --> |
311 | * @generated |
312 | */ |
313 | @Override |
314 | public void eUnset(int featureID) { |
315 | switch (featureID) { |
316 | case ResourcetypePackage.RESOURCE_TYPE__UNIT: |
317 | setUnit((Unit)null); |
318 | return; |
319 | case ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION: |
320 | setUnitSpecification(UNIT_SPECIFICATION_EDEFAULT); |
321 | return; |
322 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
323 | getResourceProvidedRoles__ResourceInterfaceProvidingEntity().clear(); |
324 | return; |
325 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
326 | setResourceRepository_ResourceType((ResourceRepository)null); |
327 | return; |
328 | } |
329 | super.eUnset(featureID); |
330 | } |
331 | |
332 | /** |
333 | * <!-- begin-user-doc --> |
334 | * <!-- end-user-doc --> |
335 | * @generated |
336 | */ |
337 | @Override |
338 | public boolean eIsSet(int featureID) { |
339 | switch (featureID) { |
340 | case ResourcetypePackage.RESOURCE_TYPE__UNIT: |
341 | return basicGetUnit() != null; |
342 | case ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION: |
343 | return UNIT_SPECIFICATION_EDEFAULT == null ? unitSpecification != null : !UNIT_SPECIFICATION_EDEFAULT.equals(unitSpecification); |
344 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
345 | return resourceProvidedRoles__ResourceInterfaceProvidingEntity != null && !resourceProvidedRoles__ResourceInterfaceProvidingEntity.isEmpty(); |
346 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_REPOSITORY_RESOURCE_TYPE: |
347 | return getResourceRepository_ResourceType() != null; |
348 | } |
349 | return super.eIsSet(featureID); |
350 | } |
351 | |
352 | /** |
353 | * <!-- begin-user-doc --> |
354 | * <!-- end-user-doc --> |
355 | * @generated |
356 | */ |
357 | @Override |
358 | public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
359 | if (baseClass == UnitCarryingElement.class) { |
360 | switch (derivedFeatureID) { |
361 | case ResourcetypePackage.RESOURCE_TYPE__UNIT: return UnitsPackage.UNIT_CARRYING_ELEMENT__UNIT; |
362 | case ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION: return UnitsPackage.UNIT_CARRYING_ELEMENT__UNIT_SPECIFICATION; |
363 | default: return -1; |
364 | } |
365 | } |
366 | if (baseClass == ResourceInterfaceProvidingEntity.class) { |
367 | switch (derivedFeatureID) { |
368 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: return EntityPackage.RESOURCE_INTERFACE_PROVIDING_ENTITY__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY; |
369 | default: return -1; |
370 | } |
371 | } |
372 | return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
373 | } |
374 | |
375 | /** |
376 | * <!-- begin-user-doc --> |
377 | * <!-- end-user-doc --> |
378 | * @generated |
379 | */ |
380 | @Override |
381 | public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
382 | if (baseClass == UnitCarryingElement.class) { |
383 | switch (baseFeatureID) { |
384 | case UnitsPackage.UNIT_CARRYING_ELEMENT__UNIT: return ResourcetypePackage.RESOURCE_TYPE__UNIT; |
385 | case UnitsPackage.UNIT_CARRYING_ELEMENT__UNIT_SPECIFICATION: return ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION; |
386 | default: return -1; |
387 | } |
388 | } |
389 | if (baseClass == ResourceInterfaceProvidingEntity.class) { |
390 | switch (baseFeatureID) { |
391 | case EntityPackage.RESOURCE_INTERFACE_PROVIDING_ENTITY__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: return ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY; |
392 | default: return -1; |
393 | } |
394 | } |
395 | return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
396 | } |
397 | |
398 | /** |
399 | * <!-- begin-user-doc --> |
400 | * <!-- end-user-doc --> |
401 | * @generated |
402 | */ |
403 | @Override |
404 | public String toString() { |
405 | if (eIsProxy()) return super.toString(); |
406 | |
407 | StringBuffer result = new StringBuffer(super.toString()); |
408 | result.append(" (unitSpecification: "); |
409 | result.append(unitSpecification); |
410 | result.append(')'); |
411 | return result.toString(); |
412 | } |
413 | |
414 | } //ResourceTypeImpl |