001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.config.impl;
008    
009    import com.hammurapi.config.ConfigPackage;
010    import com.hammurapi.config.Factory;
011    import com.hammurapi.config.MapEntry;
012    
013    import org.eclipse.emf.common.notify.Notification;
014    import org.eclipse.emf.common.notify.NotificationChain;
015    
016    import org.eclipse.emf.ecore.EClass;
017    import org.eclipse.emf.ecore.InternalEObject;
018    
019    import org.eclipse.emf.ecore.impl.ENotificationImpl;
020    import org.eclipse.emf.ecore.impl.EObjectImpl;
021    
022    /**
023     * <!-- begin-user-doc -->
024     * An implementation of the model object '<em><b>Map Entry</b></em>'.
025     * <!-- end-user-doc -->
026     * <p>
027     * The following features are implemented:
028     * <ul>
029     *   <li>{@link com.hammurapi.config.impl.MapEntryImpl#getKey <em>Key</em>}</li>
030     *   <li>{@link com.hammurapi.config.impl.MapEntryImpl#getValue <em>Value</em>}</li>
031     * </ul>
032     * </p>
033     *
034     * @generated
035     */
036    public class MapEntryImpl extends EObjectImpl implements MapEntry {
037            /**
038             * The cached value of the '{@link #getKey() <em>Key</em>}' containment reference.
039             * <!-- begin-user-doc -->
040             * <!-- end-user-doc -->
041             * @see #getKey()
042             * @generated
043             * @ordered
044             */
045            protected Factory key;
046    
047            /**
048             * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
049             * <!-- begin-user-doc -->
050             * <!-- end-user-doc -->
051             * @see #getValue()
052             * @generated
053             * @ordered
054             */
055            protected Factory value;
056    
057            /**
058             * <!-- begin-user-doc -->
059             * <!-- end-user-doc -->
060             * @generated
061             */
062            protected MapEntryImpl() {
063                    super();
064            }
065    
066            /**
067             * <!-- begin-user-doc -->
068             * <!-- end-user-doc -->
069             * @generated
070             */
071            @Override
072            protected EClass eStaticClass() {
073                    return ConfigPackage.Literals.MAP_ENTRY;
074            }
075    
076            /**
077             * <!-- begin-user-doc -->
078             * <!-- end-user-doc -->
079             * @generated
080             */
081            public Factory getKey() {
082                    return key;
083            }
084    
085            /**
086             * <!-- begin-user-doc -->
087             * <!-- end-user-doc -->
088             * @generated
089             */
090            public NotificationChain basicSetKey(Factory newKey, NotificationChain msgs) {
091                    Factory oldKey = key;
092                    key = newKey;
093                    if (eNotificationRequired()) {
094                            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ConfigPackage.MAP_ENTRY__KEY, oldKey, newKey);
095                            if (msgs == null) msgs = notification; else msgs.add(notification);
096                    }
097                    return msgs;
098            }
099    
100            /**
101             * <!-- begin-user-doc -->
102             * <!-- end-user-doc -->
103             * @generated
104             */
105            public void setKey(Factory newKey) {
106                    if (newKey != key) {
107                            NotificationChain msgs = null;
108                            if (key != null)
109                                    msgs = ((InternalEObject)key).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ConfigPackage.MAP_ENTRY__KEY, null, msgs);
110                            if (newKey != null)
111                                    msgs = ((InternalEObject)newKey).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ConfigPackage.MAP_ENTRY__KEY, null, msgs);
112                            msgs = basicSetKey(newKey, msgs);
113                            if (msgs != null) msgs.dispatch();
114                    }
115                    else if (eNotificationRequired())
116                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.MAP_ENTRY__KEY, newKey, newKey));
117            }
118    
119            /**
120             * <!-- begin-user-doc -->
121             * <!-- end-user-doc -->
122             * @generated
123             */
124            public Factory getValue() {
125                    return value;
126            }
127    
128            /**
129             * <!-- begin-user-doc -->
130             * <!-- end-user-doc -->
131             * @generated
132             */
133            public NotificationChain basicSetValue(Factory newValue, NotificationChain msgs) {
134                    Factory oldValue = value;
135                    value = newValue;
136                    if (eNotificationRequired()) {
137                            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ConfigPackage.MAP_ENTRY__VALUE, oldValue, newValue);
138                            if (msgs == null) msgs = notification; else msgs.add(notification);
139                    }
140                    return msgs;
141            }
142    
143            /**
144             * <!-- begin-user-doc -->
145             * <!-- end-user-doc -->
146             * @generated
147             */
148            public void setValue(Factory newValue) {
149                    if (newValue != value) {
150                            NotificationChain msgs = null;
151                            if (value != null)
152                                    msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ConfigPackage.MAP_ENTRY__VALUE, null, msgs);
153                            if (newValue != null)
154                                    msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ConfigPackage.MAP_ENTRY__VALUE, null, msgs);
155                            msgs = basicSetValue(newValue, msgs);
156                            if (msgs != null) msgs.dispatch();
157                    }
158                    else if (eNotificationRequired())
159                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.MAP_ENTRY__VALUE, newValue, newValue));
160            }
161    
162            /**
163             * <!-- begin-user-doc -->
164             * <!-- end-user-doc -->
165             * @generated
166             */
167            @Override
168            public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
169                    switch (featureID) {
170                            case ConfigPackage.MAP_ENTRY__KEY:
171                                    return basicSetKey(null, msgs);
172                            case ConfigPackage.MAP_ENTRY__VALUE:
173                                    return basicSetValue(null, msgs);
174                    }
175                    return super.eInverseRemove(otherEnd, featureID, msgs);
176            }
177    
178            /**
179             * <!-- begin-user-doc -->
180             * <!-- end-user-doc -->
181             * @generated
182             */
183            @Override
184            public Object eGet(int featureID, boolean resolve, boolean coreType) {
185                    switch (featureID) {
186                            case ConfigPackage.MAP_ENTRY__KEY:
187                                    return getKey();
188                            case ConfigPackage.MAP_ENTRY__VALUE:
189                                    return getValue();
190                    }
191                    return super.eGet(featureID, resolve, coreType);
192            }
193    
194            /**
195             * <!-- begin-user-doc -->
196             * <!-- end-user-doc -->
197             * @generated
198             */
199            @Override
200            public void eSet(int featureID, Object newValue) {
201                    switch (featureID) {
202                            case ConfigPackage.MAP_ENTRY__KEY:
203                                    setKey((Factory)newValue);
204                                    return;
205                            case ConfigPackage.MAP_ENTRY__VALUE:
206                                    setValue((Factory)newValue);
207                                    return;
208                    }
209                    super.eSet(featureID, newValue);
210            }
211    
212            /**
213             * <!-- begin-user-doc -->
214             * <!-- end-user-doc -->
215             * @generated
216             */
217            @Override
218            public void eUnset(int featureID) {
219                    switch (featureID) {
220                            case ConfigPackage.MAP_ENTRY__KEY:
221                                    setKey((Factory)null);
222                                    return;
223                            case ConfigPackage.MAP_ENTRY__VALUE:
224                                    setValue((Factory)null);
225                                    return;
226                    }
227                    super.eUnset(featureID);
228            }
229    
230            /**
231             * <!-- begin-user-doc -->
232             * <!-- end-user-doc -->
233             * @generated
234             */
235            @Override
236            public boolean eIsSet(int featureID) {
237                    switch (featureID) {
238                            case ConfigPackage.MAP_ENTRY__KEY:
239                                    return key != null;
240                            case ConfigPackage.MAP_ENTRY__VALUE:
241                                    return value != null;
242                    }
243                    return super.eIsSet(featureID);
244            }
245    
246    } //MapEntryImpl