1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package LqnCore.impl; |
8 | |
9 | import LqnCore.BindType; |
10 | import LqnCore.InterfaceType; |
11 | import LqnCore.LqnCorePackage; |
12 | import LqnCore.SlotType; |
13 | |
14 | import java.util.Collection; |
15 | |
16 | import org.eclipse.emf.common.notify.Notification; |
17 | import org.eclipse.emf.common.notify.NotificationChain; |
18 | |
19 | import org.eclipse.emf.common.util.EList; |
20 | |
21 | import org.eclipse.emf.ecore.EClass; |
22 | import org.eclipse.emf.ecore.InternalEObject; |
23 | |
24 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
25 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
26 | |
27 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
28 | import org.eclipse.emf.ecore.util.InternalEList; |
29 | |
30 | /** |
31 | * <!-- begin-user-doc --> |
32 | * An implementation of the model object '<em><b>Slot Type</b></em>'. |
33 | * <!-- end-user-doc --> |
34 | * <p> |
35 | * The following features are implemented: |
36 | * <ul> |
37 | * <li>{@link LqnCore.impl.SlotTypeImpl#getInterface <em>Interface</em>}</li> |
38 | * <li>{@link LqnCore.impl.SlotTypeImpl#getBinding <em>Binding</em>}</li> |
39 | * <li>{@link LqnCore.impl.SlotTypeImpl#getBindTarget <em>Bind Target</em>}</li> |
40 | * <li>{@link LqnCore.impl.SlotTypeImpl#getId <em>Id</em>}</li> |
41 | * <li>{@link LqnCore.impl.SlotTypeImpl#getReplicNum <em>Replic Num</em>}</li> |
42 | * </ul> |
43 | * </p> |
44 | * |
45 | * @generated |
46 | */ |
47 | public class SlotTypeImpl extends EObjectImpl implements SlotType { |
48 | /** |
49 | * The cached value of the '{@link #getInterface() <em>Interface</em>}' containment reference. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @see #getInterface() |
53 | * @generated |
54 | * @ordered |
55 | */ |
56 | protected InterfaceType interface_; |
57 | |
58 | /** |
59 | * The cached value of the '{@link #getBinding() <em>Binding</em>}' containment reference list. |
60 | * <!-- begin-user-doc --> |
61 | * <!-- end-user-doc --> |
62 | * @see #getBinding() |
63 | * @generated |
64 | * @ordered |
65 | */ |
66 | protected EList<BindType> binding; |
67 | |
68 | /** |
69 | * The default value of the '{@link #getBindTarget() <em>Bind Target</em>}' attribute. |
70 | * <!-- begin-user-doc --> |
71 | * <!-- end-user-doc --> |
72 | * @see #getBindTarget() |
73 | * @generated |
74 | * @ordered |
75 | */ |
76 | protected static final String BIND_TARGET_EDEFAULT = null; |
77 | |
78 | /** |
79 | * The cached value of the '{@link #getBindTarget() <em>Bind Target</em>}' attribute. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @see #getBindTarget() |
83 | * @generated |
84 | * @ordered |
85 | */ |
86 | protected String bindTarget = BIND_TARGET_EDEFAULT; |
87 | |
88 | /** |
89 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. |
90 | * <!-- begin-user-doc --> |
91 | * <!-- end-user-doc --> |
92 | * @see #getId() |
93 | * @generated |
94 | * @ordered |
95 | */ |
96 | protected static final String ID_EDEFAULT = null; |
97 | |
98 | /** |
99 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. |
100 | * <!-- begin-user-doc --> |
101 | * <!-- end-user-doc --> |
102 | * @see #getId() |
103 | * @generated |
104 | * @ordered |
105 | */ |
106 | protected String id = ID_EDEFAULT; |
107 | |
108 | /** |
109 | * The default value of the '{@link #getReplicNum() <em>Replic Num</em>}' attribute. |
110 | * <!-- begin-user-doc --> |
111 | * <!-- end-user-doc --> |
112 | * @see #getReplicNum() |
113 | * @generated |
114 | * @ordered |
115 | */ |
116 | protected static final int REPLIC_NUM_EDEFAULT = 0; |
117 | |
118 | /** |
119 | * The cached value of the '{@link #getReplicNum() <em>Replic Num</em>}' attribute. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @see #getReplicNum() |
123 | * @generated |
124 | * @ordered |
125 | */ |
126 | protected int replicNum = REPLIC_NUM_EDEFAULT; |
127 | |
128 | /** |
129 | * This is true if the Replic Num attribute has been set. |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @generated |
133 | * @ordered |
134 | */ |
135 | protected boolean replicNumESet; |
136 | |
137 | /** |
138 | * <!-- begin-user-doc --> |
139 | * <!-- end-user-doc --> |
140 | * @generated |
141 | */ |
142 | protected SlotTypeImpl() { |
143 | super(); |
144 | } |
145 | |
146 | /** |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @generated |
150 | */ |
151 | @Override |
152 | protected EClass eStaticClass() { |
153 | return LqnCorePackage.Literals.SLOT_TYPE; |
154 | } |
155 | |
156 | /** |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | public InterfaceType getInterface() { |
162 | return interface_; |
163 | } |
164 | |
165 | /** |
166 | * <!-- begin-user-doc --> |
167 | * <!-- end-user-doc --> |
168 | * @generated |
169 | */ |
170 | public NotificationChain basicSetInterface(InterfaceType newInterface, NotificationChain msgs) { |
171 | InterfaceType oldInterface = interface_; |
172 | interface_ = newInterface; |
173 | if (eNotificationRequired()) { |
174 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LqnCorePackage.SLOT_TYPE__INTERFACE, oldInterface, newInterface); |
175 | if (msgs == null) msgs = notification; else msgs.add(notification); |
176 | } |
177 | return msgs; |
178 | } |
179 | |
180 | /** |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | public void setInterface(InterfaceType newInterface) { |
186 | if (newInterface != interface_) { |
187 | NotificationChain msgs = null; |
188 | if (interface_ != null) |
189 | msgs = ((InternalEObject)interface_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LqnCorePackage.SLOT_TYPE__INTERFACE, null, msgs); |
190 | if (newInterface != null) |
191 | msgs = ((InternalEObject)newInterface).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LqnCorePackage.SLOT_TYPE__INTERFACE, null, msgs); |
192 | msgs = basicSetInterface(newInterface, msgs); |
193 | if (msgs != null) msgs.dispatch(); |
194 | } |
195 | else if (eNotificationRequired()) |
196 | eNotify(new ENotificationImpl(this, Notification.SET, LqnCorePackage.SLOT_TYPE__INTERFACE, newInterface, newInterface)); |
197 | } |
198 | |
199 | /** |
200 | * <!-- begin-user-doc --> |
201 | * <!-- end-user-doc --> |
202 | * @generated |
203 | */ |
204 | public EList<BindType> getBinding() { |
205 | if (binding == null) { |
206 | binding = new EObjectContainmentEList<BindType>(BindType.class, this, LqnCorePackage.SLOT_TYPE__BINDING); |
207 | } |
208 | return binding; |
209 | } |
210 | |
211 | /** |
212 | * <!-- begin-user-doc --> |
213 | * <!-- end-user-doc --> |
214 | * @generated |
215 | */ |
216 | public String getBindTarget() { |
217 | return bindTarget; |
218 | } |
219 | |
220 | /** |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | public void setBindTarget(String newBindTarget) { |
226 | String oldBindTarget = bindTarget; |
227 | bindTarget = newBindTarget; |
228 | if (eNotificationRequired()) |
229 | eNotify(new ENotificationImpl(this, Notification.SET, LqnCorePackage.SLOT_TYPE__BIND_TARGET, oldBindTarget, bindTarget)); |
230 | } |
231 | |
232 | /** |
233 | * <!-- begin-user-doc --> |
234 | * <!-- end-user-doc --> |
235 | * @generated |
236 | */ |
237 | public String getId() { |
238 | return id; |
239 | } |
240 | |
241 | /** |
242 | * <!-- begin-user-doc --> |
243 | * <!-- end-user-doc --> |
244 | * @generated |
245 | */ |
246 | public void setId(String newId) { |
247 | String oldId = id; |
248 | id = newId; |
249 | if (eNotificationRequired()) |
250 | eNotify(new ENotificationImpl(this, Notification.SET, LqnCorePackage.SLOT_TYPE__ID, oldId, id)); |
251 | } |
252 | |
253 | /** |
254 | * <!-- begin-user-doc --> |
255 | * <!-- end-user-doc --> |
256 | * @generated |
257 | */ |
258 | public int getReplicNum() { |
259 | return replicNum; |
260 | } |
261 | |
262 | /** |
263 | * <!-- begin-user-doc --> |
264 | * <!-- end-user-doc --> |
265 | * @generated |
266 | */ |
267 | public void setReplicNum(int newReplicNum) { |
268 | int oldReplicNum = replicNum; |
269 | replicNum = newReplicNum; |
270 | boolean oldReplicNumESet = replicNumESet; |
271 | replicNumESet = true; |
272 | if (eNotificationRequired()) |
273 | eNotify(new ENotificationImpl(this, Notification.SET, LqnCorePackage.SLOT_TYPE__REPLIC_NUM, oldReplicNum, replicNum, !oldReplicNumESet)); |
274 | } |
275 | |
276 | /** |
277 | * <!-- begin-user-doc --> |
278 | * <!-- end-user-doc --> |
279 | * @generated |
280 | */ |
281 | public void unsetReplicNum() { |
282 | int oldReplicNum = replicNum; |
283 | boolean oldReplicNumESet = replicNumESet; |
284 | replicNum = REPLIC_NUM_EDEFAULT; |
285 | replicNumESet = false; |
286 | if (eNotificationRequired()) |
287 | eNotify(new ENotificationImpl(this, Notification.UNSET, LqnCorePackage.SLOT_TYPE__REPLIC_NUM, oldReplicNum, REPLIC_NUM_EDEFAULT, oldReplicNumESet)); |
288 | } |
289 | |
290 | /** |
291 | * <!-- begin-user-doc --> |
292 | * <!-- end-user-doc --> |
293 | * @generated |
294 | */ |
295 | public boolean isSetReplicNum() { |
296 | return replicNumESet; |
297 | } |
298 | |
299 | /** |
300 | * <!-- begin-user-doc --> |
301 | * <!-- end-user-doc --> |
302 | * @generated |
303 | */ |
304 | @Override |
305 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
306 | switch (featureID) { |
307 | case LqnCorePackage.SLOT_TYPE__INTERFACE: |
308 | return basicSetInterface(null, msgs); |
309 | case LqnCorePackage.SLOT_TYPE__BINDING: |
310 | return ((InternalEList<?>)getBinding()).basicRemove(otherEnd, msgs); |
311 | } |
312 | return super.eInverseRemove(otherEnd, featureID, msgs); |
313 | } |
314 | |
315 | /** |
316 | * <!-- begin-user-doc --> |
317 | * <!-- end-user-doc --> |
318 | * @generated |
319 | */ |
320 | @Override |
321 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
322 | switch (featureID) { |
323 | case LqnCorePackage.SLOT_TYPE__INTERFACE: |
324 | return getInterface(); |
325 | case LqnCorePackage.SLOT_TYPE__BINDING: |
326 | return getBinding(); |
327 | case LqnCorePackage.SLOT_TYPE__BIND_TARGET: |
328 | return getBindTarget(); |
329 | case LqnCorePackage.SLOT_TYPE__ID: |
330 | return getId(); |
331 | case LqnCorePackage.SLOT_TYPE__REPLIC_NUM: |
332 | return new Integer(getReplicNum()); |
333 | } |
334 | return super.eGet(featureID, resolve, coreType); |
335 | } |
336 | |
337 | /** |
338 | * <!-- begin-user-doc --> |
339 | * <!-- end-user-doc --> |
340 | * @generated |
341 | */ |
342 | @SuppressWarnings("unchecked") |
343 | @Override |
344 | public void eSet(int featureID, Object newValue) { |
345 | switch (featureID) { |
346 | case LqnCorePackage.SLOT_TYPE__INTERFACE: |
347 | setInterface((InterfaceType)newValue); |
348 | return; |
349 | case LqnCorePackage.SLOT_TYPE__BINDING: |
350 | getBinding().clear(); |
351 | getBinding().addAll((Collection<? extends BindType>)newValue); |
352 | return; |
353 | case LqnCorePackage.SLOT_TYPE__BIND_TARGET: |
354 | setBindTarget((String)newValue); |
355 | return; |
356 | case LqnCorePackage.SLOT_TYPE__ID: |
357 | setId((String)newValue); |
358 | return; |
359 | case LqnCorePackage.SLOT_TYPE__REPLIC_NUM: |
360 | setReplicNum(((Integer)newValue).intValue()); |
361 | return; |
362 | } |
363 | super.eSet(featureID, newValue); |
364 | } |
365 | |
366 | /** |
367 | * <!-- begin-user-doc --> |
368 | * <!-- end-user-doc --> |
369 | * @generated |
370 | */ |
371 | @Override |
372 | public void eUnset(int featureID) { |
373 | switch (featureID) { |
374 | case LqnCorePackage.SLOT_TYPE__INTERFACE: |
375 | setInterface((InterfaceType)null); |
376 | return; |
377 | case LqnCorePackage.SLOT_TYPE__BINDING: |
378 | getBinding().clear(); |
379 | return; |
380 | case LqnCorePackage.SLOT_TYPE__BIND_TARGET: |
381 | setBindTarget(BIND_TARGET_EDEFAULT); |
382 | return; |
383 | case LqnCorePackage.SLOT_TYPE__ID: |
384 | setId(ID_EDEFAULT); |
385 | return; |
386 | case LqnCorePackage.SLOT_TYPE__REPLIC_NUM: |
387 | unsetReplicNum(); |
388 | return; |
389 | } |
390 | super.eUnset(featureID); |
391 | } |
392 | |
393 | /** |
394 | * <!-- begin-user-doc --> |
395 | * <!-- end-user-doc --> |
396 | * @generated |
397 | */ |
398 | @Override |
399 | public boolean eIsSet(int featureID) { |
400 | switch (featureID) { |
401 | case LqnCorePackage.SLOT_TYPE__INTERFACE: |
402 | return interface_ != null; |
403 | case LqnCorePackage.SLOT_TYPE__BINDING: |
404 | return binding != null && !binding.isEmpty(); |
405 | case LqnCorePackage.SLOT_TYPE__BIND_TARGET: |
406 | return BIND_TARGET_EDEFAULT == null ? bindTarget != null : !BIND_TARGET_EDEFAULT.equals(bindTarget); |
407 | case LqnCorePackage.SLOT_TYPE__ID: |
408 | return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); |
409 | case LqnCorePackage.SLOT_TYPE__REPLIC_NUM: |
410 | return isSetReplicNum(); |
411 | } |
412 | return super.eIsSet(featureID); |
413 | } |
414 | |
415 | /** |
416 | * <!-- begin-user-doc --> |
417 | * <!-- end-user-doc --> |
418 | * @generated |
419 | */ |
420 | @Override |
421 | public String toString() { |
422 | if (eIsProxy()) return super.toString(); |
423 | |
424 | StringBuffer result = new StringBuffer(super.toString()); |
425 | result.append(" (bindTarget: "); |
426 | result.append(bindTarget); |
427 | result.append(", id: "); |
428 | result.append(id); |
429 | result.append(", replicNum: "); |
430 | if (replicNumESet) result.append(replicNum); else result.append("<unset>"); |
431 | result.append(')'); |
432 | return result.toString(); |
433 | } |
434 | |
435 | } //SlotTypeImpl |