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