001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.party.impl;
008    
009    import com.hammurapi.party.PartyPackage;
010    import com.hammurapi.party.Tag;
011    
012    import java.util.Collection;
013    
014    import org.eclipse.emf.common.notify.Notification;
015    
016    import org.eclipse.emf.common.util.EList;
017    
018    import org.eclipse.emf.ecore.EClass;
019    
020    import org.eclipse.emf.ecore.impl.ENotificationImpl;
021    import org.eclipse.emf.ecore.impl.EObjectImpl;
022    
023    import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
024    
025    /**
026     * <!-- begin-user-doc -->
027     * An implementation of the model object '<em><b>Tag</b></em>'.
028     * <!-- end-user-doc -->
029     * <p>
030     * The following features are implemented:
031     * <ul>
032     *   <li>{@link com.hammurapi.party.impl.TagImpl#getName <em>Name</em>}</li>
033     *   <li>{@link com.hammurapi.party.impl.TagImpl#getValue <em>Value</em>}</li>
034     *   <li>{@link com.hammurapi.party.impl.TagImpl#getComment <em>Comment</em>}</li>
035     * </ul>
036     * </p>
037     *
038     * @generated
039     */
040    public class TagImpl extends EObjectImpl implements Tag {
041            /**
042             * The default value of the '{@link #getName() <em>Name</em>}' attribute.
043             * <!-- begin-user-doc -->
044             * <!-- end-user-doc -->
045             * @see #getName()
046             * @generated
047             * @ordered
048             */
049            protected static final String NAME_EDEFAULT = null;
050    
051            /**
052             * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
053             * <!-- begin-user-doc -->
054             * <!-- end-user-doc -->
055             * @see #getName()
056             * @generated
057             * @ordered
058             */
059            protected String name = NAME_EDEFAULT;
060    
061            /**
062             * The cached value of the '{@link #getValue() <em>Value</em>}' attribute list.
063             * <!-- begin-user-doc -->
064             * <!-- end-user-doc -->
065             * @see #getValue()
066             * @generated
067             * @ordered
068             */
069            protected EList<String> value;
070    
071            /**
072             * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
073             * <!-- begin-user-doc -->
074             * <!-- end-user-doc -->
075             * @see #getComment()
076             * @generated
077             * @ordered
078             */
079            protected static final String COMMENT_EDEFAULT = null;
080    
081            /**
082             * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
083             * <!-- begin-user-doc -->
084             * <!-- end-user-doc -->
085             * @see #getComment()
086             * @generated
087             * @ordered
088             */
089            protected String comment = COMMENT_EDEFAULT;
090    
091            /**
092             * <!-- begin-user-doc -->
093             * <!-- end-user-doc -->
094             * @generated
095             */
096            protected TagImpl() {
097                    super();
098            }
099    
100            /**
101             * <!-- begin-user-doc -->
102             * <!-- end-user-doc -->
103             * @generated
104             */
105            @Override
106            protected EClass eStaticClass() {
107                    return PartyPackage.Literals.TAG;
108            }
109    
110            /**
111             * <!-- begin-user-doc -->
112             * <!-- end-user-doc -->
113             * @generated
114             */
115            public String getName() {
116                    return name;
117            }
118    
119            /**
120             * <!-- begin-user-doc -->
121             * <!-- end-user-doc -->
122             * @generated
123             */
124            public void setName(String newName) {
125                    String oldName = name;
126                    name = newName;
127                    if (eNotificationRequired())
128                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.TAG__NAME, oldName, name));
129            }
130    
131            /**
132             * <!-- begin-user-doc -->
133             * <!-- end-user-doc -->
134             * @generated
135             */
136            public EList<String> getValue() {
137                    if (value == null) {
138                            value = new EDataTypeUniqueEList<String>(String.class, this, PartyPackage.TAG__VALUE);
139                    }
140                    return value;
141            }
142    
143            /**
144             * <!-- begin-user-doc -->
145             * <!-- end-user-doc -->
146             * @generated
147             */
148            public String getComment() {
149                    return comment;
150            }
151    
152            /**
153             * <!-- begin-user-doc -->
154             * <!-- end-user-doc -->
155             * @generated
156             */
157            public void setComment(String newComment) {
158                    String oldComment = comment;
159                    comment = newComment;
160                    if (eNotificationRequired())
161                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.TAG__COMMENT, oldComment, comment));
162            }
163    
164            /**
165             * <!-- begin-user-doc -->
166             * <!-- end-user-doc -->
167             * @generated
168             */
169            @Override
170            public Object eGet(int featureID, boolean resolve, boolean coreType) {
171                    switch (featureID) {
172                            case PartyPackage.TAG__NAME:
173                                    return getName();
174                            case PartyPackage.TAG__VALUE:
175                                    return getValue();
176                            case PartyPackage.TAG__COMMENT:
177                                    return getComment();
178                    }
179                    return super.eGet(featureID, resolve, coreType);
180            }
181    
182            /**
183             * <!-- begin-user-doc -->
184             * <!-- end-user-doc -->
185             * @generated
186             */
187            @SuppressWarnings("unchecked")
188            @Override
189            public void eSet(int featureID, Object newValue) {
190                    switch (featureID) {
191                            case PartyPackage.TAG__NAME:
192                                    setName((String)newValue);
193                                    return;
194                            case PartyPackage.TAG__VALUE:
195                                    getValue().clear();
196                                    getValue().addAll((Collection<? extends String>)newValue);
197                                    return;
198                            case PartyPackage.TAG__COMMENT:
199                                    setComment((String)newValue);
200                                    return;
201                    }
202                    super.eSet(featureID, newValue);
203            }
204    
205            /**
206             * <!-- begin-user-doc -->
207             * <!-- end-user-doc -->
208             * @generated
209             */
210            @Override
211            public void eUnset(int featureID) {
212                    switch (featureID) {
213                            case PartyPackage.TAG__NAME:
214                                    setName(NAME_EDEFAULT);
215                                    return;
216                            case PartyPackage.TAG__VALUE:
217                                    getValue().clear();
218                                    return;
219                            case PartyPackage.TAG__COMMENT:
220                                    setComment(COMMENT_EDEFAULT);
221                                    return;
222                    }
223                    super.eUnset(featureID);
224            }
225    
226            /**
227             * <!-- begin-user-doc -->
228             * <!-- end-user-doc -->
229             * @generated
230             */
231            @Override
232            public boolean eIsSet(int featureID) {
233                    switch (featureID) {
234                            case PartyPackage.TAG__NAME:
235                                    return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
236                            case PartyPackage.TAG__VALUE:
237                                    return value != null && !value.isEmpty();
238                            case PartyPackage.TAG__COMMENT:
239                                    return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
240                    }
241                    return super.eIsSet(featureID);
242            }
243    
244            /**
245             * <!-- begin-user-doc -->
246             * <!-- end-user-doc -->
247             * @generated
248             */
249            @Override
250            public String toString() {
251                    if (eIsProxy()) return super.toString();
252    
253                    StringBuffer result = new StringBuffer(super.toString());
254                    result.append(" (name: ");
255                    result.append(name);
256                    result.append(", value: ");
257                    result.append(value);
258                    result.append(", comment: ");
259                    result.append(comment);
260                    result.append(')');
261                    return result.toString();
262            }
263    
264    } //TagImpl