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