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