KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > change > impl > EObjectToChangesMapEntryImpl


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EObjectToChangesMapEntryImpl.java,v 1.9 2005/06/12 13:29:48 emerks Exp $
16  */

17 package org.eclipse.emf.ecore.change.impl;
18
19
20 import java.util.Collection JavaDoc;
21
22 import org.eclipse.emf.common.notify.Notification;
23 import org.eclipse.emf.common.notify.NotificationChain;
24 import org.eclipse.emf.common.util.BasicEMap;
25 import org.eclipse.emf.common.util.EList;
26 import org.eclipse.emf.common.util.EMap;
27 import org.eclipse.emf.ecore.EClass;
28 import org.eclipse.emf.ecore.EObject;
29 import org.eclipse.emf.ecore.EStructuralFeature;
30 import org.eclipse.emf.ecore.InternalEObject;
31 import org.eclipse.emf.ecore.change.ChangePackage;
32 import org.eclipse.emf.ecore.change.FeatureChange;
33 import org.eclipse.emf.ecore.impl.ENotificationImpl;
34 import org.eclipse.emf.ecore.impl.EObjectImpl;
35 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
36 import org.eclipse.emf.ecore.util.InternalEList;
37
38
39 /**
40  * <!-- begin-user-doc -->
41  * An implementation of the model object '<em><b>EObject To Changes Map Entry</b></em>'.
42  * <!-- end-user-doc -->
43  * <p>
44  * The following features are implemented:
45  * <ul>
46  * <li>{@link org.eclipse.emf.ecore.change.impl.EObjectToChangesMapEntryImpl#getTypedKey <em>Key</em>}</li>
47  * <li>{@link org.eclipse.emf.ecore.change.impl.EObjectToChangesMapEntryImpl#getTypedValue <em>Value</em>}</li>
48  * </ul>
49  * </p>
50  *
51  * @generated
52  */

53 public class EObjectToChangesMapEntryImpl extends EObjectImpl implements BasicEMap.Entry
54 {
55   /**
56    * The bit of {@link #eFlags} that is used to represent if key is a proxy.
57    */

58   protected static final int EPROXY_KEY = ELAST_EOBJECT_FLAG << 1;
59   
60   /**
61    * The cached value of the '{@link #getTypedKey() <em>Key</em>}' reference.
62    * <!-- begin-user-doc -->
63    * <!-- end-user-doc -->
64    * @see #getTypedKey()
65    * @generated
66    * @ordered
67    */

68   protected EObject key = null;
69
70   /**
71    * The cached value of the '{@link #getTypedValue() <em>Value</em>}' containment reference list.
72    * <!-- begin-user-doc -->
73    * <!-- end-user-doc -->
74    * @see #getTypedValue()
75    * @generated
76    * @ordered
77    */

78   protected EList value = null;
79
80   /**
81    * <!-- begin-user-doc -->
82    * <!-- end-user-doc -->
83    * @generated
84    */

85   protected EObjectToChangesMapEntryImpl()
86   {
87     super();
88   }
89
90   /**
91    * <!-- begin-user-doc -->
92    * <!-- end-user-doc -->
93    * @generated
94    */

95   protected EClass eStaticClass()
96   {
97     return ChangePackage.eINSTANCE.getEObjectToChangesMapEntry();
98   }
99
100   /**
101    * <!-- begin-user-doc -->
102    * <!-- end-user-doc -->
103    * @generated
104    */

105   public EObject getTypedKeyGen()
106   {
107     if (key != null && key.eIsProxy())
108     {
109       EObject oldKey = key;
110       key = (EObject)eResolveProxy((InternalEObject)key);
111       if (key != oldKey)
112       {
113         if (eNotificationRequired())
114           eNotify(new ENotificationImpl(this, Notification.RESOLVE, ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__KEY, oldKey, key));
115       }
116     }
117     return key;
118   }
119
120   /**
121    * <!-- begin-user-doc -->
122    * <!-- end-user-doc -->
123    * @generated NOT
124    */

125   public EObject getTypedKey()
126   {
127     if ((eFlags & EPROXY_KEY) != 0)
128     {
129       EObject newKey = getTypedKeyGen();
130       if (!newKey.eIsProxy())
131       {
132         eFlags &= ~EPROXY_KEY;
133       }
134     }
135     return key;
136   }
137
138   /**
139    * <!-- begin-user-doc -->
140    * <!-- end-user-doc -->
141    * @generated
142    */

143   public EObject basicGetTypedKey()
144   {
145     return key;
146   }
147
148   /**
149    * <!-- begin-user-doc -->
150    * <!-- end-user-doc -->
151    * @generated
152    */

153   public void setTypedKeyGen(EObject newKey)
154   {
155     EObject oldKey = key;
156     key = newKey;
157     if (eNotificationRequired())
158       eNotify(new ENotificationImpl(this, Notification.SET, ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__KEY, oldKey, key));
159   }
160
161   /**
162    * <!-- begin-user-doc -->
163    * <!-- end-user-doc -->
164    * @generated NOT
165    */

166   public void setTypedKey(EObject newKey)
167   {
168     setTypedKeyGen(newKey);
169     if (key != null)
170     {
171       eFlags |= EPROXY_KEY;
172     }
173     else
174     {
175       eFlags &= ~EPROXY_KEY;
176     }
177   }
178
179   /**
180    * <!-- begin-user-doc -->
181    * <!-- end-user-doc -->
182    * @generated
183    */

184   public EList getTypedValue()
185   {
186     if (value == null)
187     {
188       value = new EObjectContainmentEList(FeatureChange.class, this, ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__VALUE);
189     }
190     return value;
191   }
192
193   /**
194    * <!-- begin-user-doc -->
195    * <!-- end-user-doc -->
196    * @generated
197    */

198   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
199   {
200     if (featureID >= 0)
201     {
202       switch (eDerivedStructuralFeatureID(featureID, baseClass))
203       {
204         case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__VALUE:
205           return ((InternalEList)getTypedValue()).basicRemove(otherEnd, msgs);
206         default:
207           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
208       }
209     }
210     return eBasicSetContainer(null, featureID, msgs);
211   }
212
213   /**
214    * <!-- begin-user-doc -->
215    * <!-- end-user-doc -->
216    * @generated
217    */

218   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
219   {
220     switch (eDerivedStructuralFeatureID(eFeature))
221     {
222       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__KEY:
223         if (resolve) return getTypedKey();
224         return basicGetTypedKey();
225       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__VALUE:
226         return getTypedValue();
227     }
228     return eDynamicGet(eFeature, resolve);
229   }
230
231   /**
232    * <!-- begin-user-doc -->
233    * <!-- end-user-doc -->
234    * @generated
235    */

236   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
237   {
238     switch (eDerivedStructuralFeatureID(eFeature))
239     {
240       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__KEY:
241         setTypedKey((EObject)newValue);
242         return;
243       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__VALUE:
244         getTypedValue().clear();
245         getTypedValue().addAll((Collection JavaDoc)newValue);
246         return;
247     }
248     eDynamicSet(eFeature, newValue);
249   }
250
251   /**
252    * <!-- begin-user-doc -->
253    * <!-- end-user-doc -->
254    * @generated
255    */

256   public void eUnset(EStructuralFeature eFeature)
257   {
258     switch (eDerivedStructuralFeatureID(eFeature))
259     {
260       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__KEY:
261         setTypedKey((EObject)null);
262         return;
263       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__VALUE:
264         getTypedValue().clear();
265         return;
266     }
267     eDynamicUnset(eFeature);
268   }
269
270   /**
271    * <!-- begin-user-doc -->
272    * <!-- end-user-doc -->
273    * @generated
274    */

275   public boolean eIsSet(EStructuralFeature eFeature)
276   {
277     switch (eDerivedStructuralFeatureID(eFeature))
278     {
279       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__KEY:
280         return key != null;
281       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY__VALUE:
282         return value != null && !value.isEmpty();
283     }
284     return eDynamicIsSet(eFeature);
285   }
286
287   /**
288    * <!-- begin-user-doc -->
289    * <!-- end-user-doc -->
290    * @generated
291    */

292   protected int hash = -1;
293
294   /**
295    * <!-- begin-user-doc -->
296    * <!-- end-user-doc -->
297    * @generated
298    */

299   public int getHash()
300   {
301     if (hash == -1)
302     {
303       Object JavaDoc theKey = getKey();
304       hash = (theKey == null ? 0 : theKey.hashCode());
305     }
306     return hash;
307   }
308
309   /**
310    * <!-- begin-user-doc -->
311    * <!-- end-user-doc -->
312    * @generated
313    */

314   public void setHash(int hash)
315   {
316     this.hash = hash;
317   }
318
319   /**
320    * <!-- begin-user-doc -->
321    * <!-- end-user-doc -->
322    * @generated
323    */

324   public Object JavaDoc getKey()
325   {
326     return getTypedKey();
327   }
328
329   /**
330    * <!-- begin-user-doc -->
331    * <!-- end-user-doc -->
332    * @generated
333    */

334   public void setKey(Object JavaDoc key)
335   {
336     setTypedKey((EObject)key);
337   }
338
339   /**
340    * <!-- begin-user-doc -->
341    * <!-- end-user-doc -->
342    * @generated
343    */

344   public Object JavaDoc getValue()
345   {
346     return getTypedValue();
347   }
348
349   /**
350    * <!-- begin-user-doc -->
351    * <!-- end-user-doc -->
352    * @generated
353    */

354   public Object JavaDoc setValue(Object JavaDoc value)
355   {
356     Object JavaDoc oldValue = getValue();
357     getTypedValue().clear();
358     getTypedValue().addAll((Collection JavaDoc)value);
359     return oldValue;
360   }
361
362   /**
363    * <!-- begin-user-doc -->
364    * <!-- end-user-doc -->
365    * @generated
366    */

367   public EMap getEMap()
368   {
369     EObject container = eContainer();
370     return container == null ? null : (EMap)container.eGet(eContainmentFeature());
371   }
372
373 } //EObjectToChangesMapEntryImpl
374
Popular Tags