1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTRelation.impl; |
8 | |
9 | import EMOF.Property; |
10 | |
11 | import EMOF.impl.ElementImpl; |
12 | |
13 | import QVTRelation.Key; |
14 | import QVTRelation.QVTRelationPackage; |
15 | import QVTRelation.RelationalTransformation; |
16 | |
17 | import java.util.Collection; |
18 | |
19 | import org.eclipse.emf.common.notify.Notification; |
20 | import org.eclipse.emf.common.notify.NotificationChain; |
21 | |
22 | import org.eclipse.emf.common.util.EList; |
23 | |
24 | import org.eclipse.emf.ecore.EClass; |
25 | import org.eclipse.emf.ecore.InternalEObject; |
26 | |
27 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
28 | |
29 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
30 | import org.eclipse.emf.ecore.util.EcoreUtil; |
31 | |
32 | /** |
33 | * <!-- begin-user-doc --> |
34 | * An implementation of the model object '<em><b>Key</b></em>'. |
35 | * <!-- end-user-doc --> |
36 | * <p> |
37 | * The following features are implemented: |
38 | * <ul> |
39 | * <li>{@link QVTRelation.impl.KeyImpl#getIdentifies <em>Identifies</em>}</li> |
40 | * <li>{@link QVTRelation.impl.KeyImpl#getOppositePart <em>Opposite Part</em>}</li> |
41 | * <li>{@link QVTRelation.impl.KeyImpl#getPart <em>Part</em>}</li> |
42 | * <li>{@link QVTRelation.impl.KeyImpl#getTransformation <em>Transformation</em>}</li> |
43 | * </ul> |
44 | * </p> |
45 | * |
46 | * @generated |
47 | */ |
48 | public class KeyImpl extends ElementImpl implements Key { |
49 | /** |
50 | * The cached value of the '{@link #getIdentifies() <em>Identifies</em>}' reference. |
51 | * <!-- begin-user-doc --> |
52 | * <!-- end-user-doc --> |
53 | * @see #getIdentifies() |
54 | * @generated |
55 | * @ordered |
56 | */ |
57 | protected EMOF.Class identifies; |
58 | |
59 | /** |
60 | * The cached value of the '{@link #getOppositePart() <em>Opposite Part</em>}' reference list. |
61 | * <!-- begin-user-doc --> |
62 | * <!-- end-user-doc --> |
63 | * @see #getOppositePart() |
64 | * @generated |
65 | * @ordered |
66 | */ |
67 | protected EList<Property> oppositePart; |
68 | |
69 | /** |
70 | * The cached value of the '{@link #getPart() <em>Part</em>}' reference list. |
71 | * <!-- begin-user-doc --> |
72 | * <!-- end-user-doc --> |
73 | * @see #getPart() |
74 | * @generated |
75 | * @ordered |
76 | */ |
77 | protected EList<Property> part; |
78 | |
79 | /** |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected KeyImpl() { |
85 | super(); |
86 | } |
87 | |
88 | /** |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @generated |
92 | */ |
93 | @Override |
94 | protected EClass eStaticClass() { |
95 | return QVTRelationPackage.Literals.KEY; |
96 | } |
97 | |
98 | /** |
99 | * <!-- begin-user-doc --> |
100 | * <!-- end-user-doc --> |
101 | * @generated |
102 | */ |
103 | public EMOF.Class getIdentifies() { |
104 | if (identifies != null && identifies.eIsProxy()) { |
105 | InternalEObject oldIdentifies = (InternalEObject)identifies; |
106 | identifies = (EMOF.Class)eResolveProxy(oldIdentifies); |
107 | if (identifies != oldIdentifies) { |
108 | if (eNotificationRequired()) |
109 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QVTRelationPackage.KEY__IDENTIFIES, oldIdentifies, identifies)); |
110 | } |
111 | } |
112 | return identifies; |
113 | } |
114 | |
115 | /** |
116 | * <!-- begin-user-doc --> |
117 | * <!-- end-user-doc --> |
118 | * @generated |
119 | */ |
120 | public EMOF.Class basicGetIdentifies() { |
121 | return identifies; |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | public void setIdentifies(EMOF.Class newIdentifies) { |
130 | EMOF.Class oldIdentifies = identifies; |
131 | identifies = newIdentifies; |
132 | if (eNotificationRequired()) |
133 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.KEY__IDENTIFIES, oldIdentifies, identifies)); |
134 | } |
135 | |
136 | /** |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | public EList<Property> getOppositePart() { |
142 | if (oppositePart == null) { |
143 | oppositePart = new EObjectResolvingEList<Property>(Property.class, this, QVTRelationPackage.KEY__OPPOSITE_PART); |
144 | } |
145 | return oppositePart; |
146 | } |
147 | |
148 | /** |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | public EList<Property> getPart() { |
154 | if (part == null) { |
155 | part = new EObjectResolvingEList<Property>(Property.class, this, QVTRelationPackage.KEY__PART); |
156 | } |
157 | return part; |
158 | } |
159 | |
160 | /** |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | public RelationalTransformation getTransformation() { |
166 | if (eContainerFeatureID() != QVTRelationPackage.KEY__TRANSFORMATION) return null; |
167 | return (RelationalTransformation)eContainer(); |
168 | } |
169 | |
170 | /** |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @generated |
174 | */ |
175 | public NotificationChain basicSetTransformation(RelationalTransformation newTransformation, NotificationChain msgs) { |
176 | msgs = eBasicSetContainer((InternalEObject)newTransformation, QVTRelationPackage.KEY__TRANSFORMATION, msgs); |
177 | return msgs; |
178 | } |
179 | |
180 | /** |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | public void setTransformation(RelationalTransformation newTransformation) { |
186 | if (newTransformation != eInternalContainer() || (eContainerFeatureID() != QVTRelationPackage.KEY__TRANSFORMATION && newTransformation != null)) { |
187 | if (EcoreUtil.isAncestor(this, newTransformation)) |
188 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
189 | NotificationChain msgs = null; |
190 | if (eInternalContainer() != null) |
191 | msgs = eBasicRemoveFromContainer(msgs); |
192 | if (newTransformation != null) |
193 | msgs = ((InternalEObject)newTransformation).eInverseAdd(this, QVTRelationPackage.RELATIONAL_TRANSFORMATION__OWNED_KEY, RelationalTransformation.class, msgs); |
194 | msgs = basicSetTransformation(newTransformation, msgs); |
195 | if (msgs != null) msgs.dispatch(); |
196 | } |
197 | else if (eNotificationRequired()) |
198 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.KEY__TRANSFORMATION, newTransformation, newTransformation)); |
199 | } |
200 | |
201 | /** |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @generated |
205 | */ |
206 | @Override |
207 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
208 | switch (featureID) { |
209 | case QVTRelationPackage.KEY__TRANSFORMATION: |
210 | if (eInternalContainer() != null) |
211 | msgs = eBasicRemoveFromContainer(msgs); |
212 | return basicSetTransformation((RelationalTransformation)otherEnd, msgs); |
213 | } |
214 | return super.eInverseAdd(otherEnd, featureID, msgs); |
215 | } |
216 | |
217 | /** |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | @Override |
223 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
224 | switch (featureID) { |
225 | case QVTRelationPackage.KEY__TRANSFORMATION: |
226 | return basicSetTransformation(null, msgs); |
227 | } |
228 | return super.eInverseRemove(otherEnd, featureID, msgs); |
229 | } |
230 | |
231 | /** |
232 | * <!-- begin-user-doc --> |
233 | * <!-- end-user-doc --> |
234 | * @generated |
235 | */ |
236 | @Override |
237 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
238 | switch (eContainerFeatureID()) { |
239 | case QVTRelationPackage.KEY__TRANSFORMATION: |
240 | return eInternalContainer().eInverseRemove(this, QVTRelationPackage.RELATIONAL_TRANSFORMATION__OWNED_KEY, RelationalTransformation.class, msgs); |
241 | } |
242 | return super.eBasicRemoveFromContainerFeature(msgs); |
243 | } |
244 | |
245 | /** |
246 | * <!-- begin-user-doc --> |
247 | * <!-- end-user-doc --> |
248 | * @generated |
249 | */ |
250 | @Override |
251 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
252 | switch (featureID) { |
253 | case QVTRelationPackage.KEY__IDENTIFIES: |
254 | if (resolve) return getIdentifies(); |
255 | return basicGetIdentifies(); |
256 | case QVTRelationPackage.KEY__OPPOSITE_PART: |
257 | return getOppositePart(); |
258 | case QVTRelationPackage.KEY__PART: |
259 | return getPart(); |
260 | case QVTRelationPackage.KEY__TRANSFORMATION: |
261 | return getTransformation(); |
262 | } |
263 | return super.eGet(featureID, resolve, coreType); |
264 | } |
265 | |
266 | /** |
267 | * <!-- begin-user-doc --> |
268 | * <!-- end-user-doc --> |
269 | * @generated |
270 | */ |
271 | @SuppressWarnings("unchecked") |
272 | @Override |
273 | public void eSet(int featureID, Object newValue) { |
274 | switch (featureID) { |
275 | case QVTRelationPackage.KEY__IDENTIFIES: |
276 | setIdentifies((EMOF.Class)newValue); |
277 | return; |
278 | case QVTRelationPackage.KEY__OPPOSITE_PART: |
279 | getOppositePart().clear(); |
280 | getOppositePart().addAll((Collection<? extends Property>)newValue); |
281 | return; |
282 | case QVTRelationPackage.KEY__PART: |
283 | getPart().clear(); |
284 | getPart().addAll((Collection<? extends Property>)newValue); |
285 | return; |
286 | case QVTRelationPackage.KEY__TRANSFORMATION: |
287 | setTransformation((RelationalTransformation)newValue); |
288 | return; |
289 | } |
290 | super.eSet(featureID, newValue); |
291 | } |
292 | |
293 | /** |
294 | * <!-- begin-user-doc --> |
295 | * <!-- end-user-doc --> |
296 | * @generated |
297 | */ |
298 | @Override |
299 | public void eUnset(int featureID) { |
300 | switch (featureID) { |
301 | case QVTRelationPackage.KEY__IDENTIFIES: |
302 | setIdentifies((EMOF.Class)null); |
303 | return; |
304 | case QVTRelationPackage.KEY__OPPOSITE_PART: |
305 | getOppositePart().clear(); |
306 | return; |
307 | case QVTRelationPackage.KEY__PART: |
308 | getPart().clear(); |
309 | return; |
310 | case QVTRelationPackage.KEY__TRANSFORMATION: |
311 | setTransformation((RelationalTransformation)null); |
312 | return; |
313 | } |
314 | super.eUnset(featureID); |
315 | } |
316 | |
317 | /** |
318 | * <!-- begin-user-doc --> |
319 | * <!-- end-user-doc --> |
320 | * @generated |
321 | */ |
322 | @Override |
323 | public boolean eIsSet(int featureID) { |
324 | switch (featureID) { |
325 | case QVTRelationPackage.KEY__IDENTIFIES: |
326 | return identifies != null; |
327 | case QVTRelationPackage.KEY__OPPOSITE_PART: |
328 | return oppositePart != null && !oppositePart.isEmpty(); |
329 | case QVTRelationPackage.KEY__PART: |
330 | return part != null && !part.isEmpty(); |
331 | case QVTRelationPackage.KEY__TRANSFORMATION: |
332 | return getTransformation() != null; |
333 | } |
334 | return super.eIsSet(featureID); |
335 | } |
336 | |
337 | } //KeyImpl |