1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTBase.impl; |
8 | |
9 | import EMOF.impl.NamedElementImpl; |
10 | |
11 | import QVTBase.QVTBasePackage; |
12 | import QVTBase.Transformation; |
13 | import QVTBase.TypedModel; |
14 | |
15 | import java.util.Collection; |
16 | |
17 | import org.eclipse.emf.common.notify.Notification; |
18 | import org.eclipse.emf.common.notify.NotificationChain; |
19 | |
20 | import org.eclipse.emf.common.util.EList; |
21 | |
22 | import org.eclipse.emf.ecore.EClass; |
23 | import org.eclipse.emf.ecore.InternalEObject; |
24 | |
25 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
26 | |
27 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
28 | import org.eclipse.emf.ecore.util.EcoreUtil; |
29 | |
30 | /** |
31 | * <!-- begin-user-doc --> |
32 | * An implementation of the model object '<em><b>Typed Model</b></em>'. |
33 | * <!-- end-user-doc --> |
34 | * <p> |
35 | * The following features are implemented: |
36 | * <ul> |
37 | * <li>{@link QVTBase.impl.TypedModelImpl#getDependsOn <em>Depends On</em>}</li> |
38 | * <li>{@link QVTBase.impl.TypedModelImpl#getTransformation <em>Transformation</em>}</li> |
39 | * <li>{@link QVTBase.impl.TypedModelImpl#getUsedPackage <em>Used Package</em>}</li> |
40 | * </ul> |
41 | * </p> |
42 | * |
43 | * @generated |
44 | */ |
45 | public class TypedModelImpl extends NamedElementImpl implements TypedModel { |
46 | /** |
47 | * The cached value of the '{@link #getDependsOn() <em>Depends On</em>}' reference list. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @see #getDependsOn() |
51 | * @generated |
52 | * @ordered |
53 | */ |
54 | protected EList<TypedModel> dependsOn; |
55 | |
56 | /** |
57 | * The cached value of the '{@link #getUsedPackage() <em>Used Package</em>}' reference list. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @see #getUsedPackage() |
61 | * @generated |
62 | * @ordered |
63 | */ |
64 | protected EList<EMOF.Package> usedPackage; |
65 | |
66 | /** |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @generated |
70 | */ |
71 | protected TypedModelImpl() { |
72 | super(); |
73 | } |
74 | |
75 | /** |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @generated |
79 | */ |
80 | @Override |
81 | protected EClass eStaticClass() { |
82 | return QVTBasePackage.Literals.TYPED_MODEL; |
83 | } |
84 | |
85 | /** |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @generated |
89 | */ |
90 | public EList<TypedModel> getDependsOn() { |
91 | if (dependsOn == null) { |
92 | dependsOn = new EObjectResolvingEList<TypedModel>(TypedModel.class, this, QVTBasePackage.TYPED_MODEL__DEPENDS_ON); |
93 | } |
94 | return dependsOn; |
95 | } |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | public Transformation getTransformation() { |
103 | if (eContainerFeatureID() != QVTBasePackage.TYPED_MODEL__TRANSFORMATION) return null; |
104 | return (Transformation)eContainer(); |
105 | } |
106 | |
107 | /** |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | public NotificationChain basicSetTransformation(Transformation newTransformation, NotificationChain msgs) { |
113 | msgs = eBasicSetContainer((InternalEObject)newTransformation, QVTBasePackage.TYPED_MODEL__TRANSFORMATION, msgs); |
114 | return msgs; |
115 | } |
116 | |
117 | /** |
118 | * <!-- begin-user-doc --> |
119 | * <!-- end-user-doc --> |
120 | * @generated |
121 | */ |
122 | public void setTransformation(Transformation newTransformation) { |
123 | if (newTransformation != eInternalContainer() || (eContainerFeatureID() != QVTBasePackage.TYPED_MODEL__TRANSFORMATION && newTransformation != null)) { |
124 | if (EcoreUtil.isAncestor(this, newTransformation)) |
125 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
126 | NotificationChain msgs = null; |
127 | if (eInternalContainer() != null) |
128 | msgs = eBasicRemoveFromContainer(msgs); |
129 | if (newTransformation != null) |
130 | msgs = ((InternalEObject)newTransformation).eInverseAdd(this, QVTBasePackage.TRANSFORMATION__MODEL_PARAMETER, Transformation.class, msgs); |
131 | msgs = basicSetTransformation(newTransformation, msgs); |
132 | if (msgs != null) msgs.dispatch(); |
133 | } |
134 | else if (eNotificationRequired()) |
135 | eNotify(new ENotificationImpl(this, Notification.SET, QVTBasePackage.TYPED_MODEL__TRANSFORMATION, newTransformation, newTransformation)); |
136 | } |
137 | |
138 | /** |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | public EList<EMOF.Package> getUsedPackage() { |
144 | if (usedPackage == null) { |
145 | usedPackage = new EObjectResolvingEList<EMOF.Package>(EMOF.Package.class, this, QVTBasePackage.TYPED_MODEL__USED_PACKAGE); |
146 | } |
147 | return usedPackage; |
148 | } |
149 | |
150 | /** |
151 | * <!-- begin-user-doc --> |
152 | * <!-- end-user-doc --> |
153 | * @generated |
154 | */ |
155 | @Override |
156 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
157 | switch (featureID) { |
158 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
159 | if (eInternalContainer() != null) |
160 | msgs = eBasicRemoveFromContainer(msgs); |
161 | return basicSetTransformation((Transformation)otherEnd, msgs); |
162 | } |
163 | return super.eInverseAdd(otherEnd, featureID, msgs); |
164 | } |
165 | |
166 | /** |
167 | * <!-- begin-user-doc --> |
168 | * <!-- end-user-doc --> |
169 | * @generated |
170 | */ |
171 | @Override |
172 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
173 | switch (featureID) { |
174 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
175 | return basicSetTransformation(null, msgs); |
176 | } |
177 | return super.eInverseRemove(otherEnd, featureID, msgs); |
178 | } |
179 | |
180 | /** |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | @Override |
186 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
187 | switch (eContainerFeatureID()) { |
188 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
189 | return eInternalContainer().eInverseRemove(this, QVTBasePackage.TRANSFORMATION__MODEL_PARAMETER, Transformation.class, msgs); |
190 | } |
191 | return super.eBasicRemoveFromContainerFeature(msgs); |
192 | } |
193 | |
194 | /** |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | @Override |
200 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
201 | switch (featureID) { |
202 | case QVTBasePackage.TYPED_MODEL__DEPENDS_ON: |
203 | return getDependsOn(); |
204 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
205 | return getTransformation(); |
206 | case QVTBasePackage.TYPED_MODEL__USED_PACKAGE: |
207 | return getUsedPackage(); |
208 | } |
209 | return super.eGet(featureID, resolve, coreType); |
210 | } |
211 | |
212 | /** |
213 | * <!-- begin-user-doc --> |
214 | * <!-- end-user-doc --> |
215 | * @generated |
216 | */ |
217 | @SuppressWarnings("unchecked") |
218 | @Override |
219 | public void eSet(int featureID, Object newValue) { |
220 | switch (featureID) { |
221 | case QVTBasePackage.TYPED_MODEL__DEPENDS_ON: |
222 | getDependsOn().clear(); |
223 | getDependsOn().addAll((Collection<? extends TypedModel>)newValue); |
224 | return; |
225 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
226 | setTransformation((Transformation)newValue); |
227 | return; |
228 | case QVTBasePackage.TYPED_MODEL__USED_PACKAGE: |
229 | getUsedPackage().clear(); |
230 | getUsedPackage().addAll((Collection<? extends EMOF.Package>)newValue); |
231 | return; |
232 | } |
233 | super.eSet(featureID, newValue); |
234 | } |
235 | |
236 | /** |
237 | * <!-- begin-user-doc --> |
238 | * <!-- end-user-doc --> |
239 | * @generated |
240 | */ |
241 | @Override |
242 | public void eUnset(int featureID) { |
243 | switch (featureID) { |
244 | case QVTBasePackage.TYPED_MODEL__DEPENDS_ON: |
245 | getDependsOn().clear(); |
246 | return; |
247 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
248 | setTransformation((Transformation)null); |
249 | return; |
250 | case QVTBasePackage.TYPED_MODEL__USED_PACKAGE: |
251 | getUsedPackage().clear(); |
252 | return; |
253 | } |
254 | super.eUnset(featureID); |
255 | } |
256 | |
257 | /** |
258 | * <!-- begin-user-doc --> |
259 | * <!-- end-user-doc --> |
260 | * @generated |
261 | */ |
262 | @Override |
263 | public boolean eIsSet(int featureID) { |
264 | switch (featureID) { |
265 | case QVTBasePackage.TYPED_MODEL__DEPENDS_ON: |
266 | return dependsOn != null && !dependsOn.isEmpty(); |
267 | case QVTBasePackage.TYPED_MODEL__TRANSFORMATION: |
268 | return getTransformation() != null; |
269 | case QVTBasePackage.TYPED_MODEL__USED_PACKAGE: |
270 | return usedPackage != null && !usedPackage.isEmpty(); |
271 | } |
272 | return super.eIsSet(featureID); |
273 | } |
274 | |
275 | } //TypedModelImpl |