1 /**
2  * <copyright>
3  * </copyright>
4  *
5 
6  */
7 package org.wesnoth.wml.impl;
8 
9 import java.util.Collection;
10 
11 import org.eclipse.emf.common.notify.Notification;
12 import org.eclipse.emf.common.notify.NotificationChain;
13 
14 import org.eclipse.emf.common.util.EList;
15 
16 import org.eclipse.emf.ecore.EClass;
17 import org.eclipse.emf.ecore.InternalEObject;
18 
19 import org.eclipse.emf.ecore.impl.ENotificationImpl;
20 
21 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
22 import org.eclipse.emf.ecore.util.InternalEList;
23 
24 import org.wesnoth.wml.WMLMacroDefine;
25 import org.wesnoth.wml.WMLValuedExpression;
26 import org.wesnoth.wml.WmlPackage;
27 
28 /**
29  * <!-- begin-user-doc -->
30  * An implementation of the model object '<em><b>WML Macro Define</b></em>'.
31  * <!-- end-user-doc -->
32  * <p>
33  * The following features are implemented:
34  * <ul>
35  *   <li>{@link org.wesnoth.wml.impl.WMLMacroDefineImpl#getExpressions <em>Expressions</em>}</li>
36  *   <li>{@link org.wesnoth.wml.impl.WMLMacroDefineImpl#getEndName <em>End Name</em>}</li>
37  * </ul>
38  * </p>
39  *
40  * @generated
41  */
42 public class WMLMacroDefineImpl extends WMLRootExpressionImpl implements WMLMacroDefine
43 {
44   /**
45    * <!-- begin-user-doc -->
46    * <!-- end-user-doc -->
47    * @generated
48    */
49   private static final long serialVersionUID = 1L;
50 
51   /**
52    * The cached value of the '{@link #getExpressions() <em>Expressions</em>}' containment reference list.
53    * <!-- begin-user-doc -->
54    * <!-- end-user-doc -->
55    * @see #getExpressions()
56    * @generated
57    * @ordered
58    */
59   protected EList<WMLValuedExpression> expressions;
60 
61   /**
62    * The default value of the '{@link #getEndName() <em>End Name</em>}' attribute.
63    * <!-- begin-user-doc -->
64    * <!-- end-user-doc -->
65    * @see #getEndName()
66    * @generated
67    * @ordered
68    */
69   protected static final String END_NAME_EDEFAULT = "";
70 
71   /**
72    * The cached value of the '{@link #getEndName() <em>End Name</em>}' attribute.
73    * <!-- begin-user-doc -->
74    * <!-- end-user-doc -->
75    * @see #getEndName()
76    * @generated
77    * @ordered
78    */
79   protected String endName = END_NAME_EDEFAULT;
80 
81   /**
82    * <!-- begin-user-doc -->
83    * <!-- end-user-doc -->
84    * @generated
85    */
WMLMacroDefineImpl()86   protected WMLMacroDefineImpl()
87   {
88     super();
89   }
90 
91   /**
92    * <!-- begin-user-doc -->
93    * <!-- end-user-doc -->
94    * @generated
95    */
96   @Override
eStaticClass()97   protected EClass eStaticClass()
98   {
99     return WmlPackage.Literals.WML_MACRO_DEFINE;
100   }
101 
102   /**
103    * <!-- begin-user-doc -->
104    * <!-- end-user-doc -->
105    * @generated
106    */
getExpressions()107   public EList<WMLValuedExpression> getExpressions()
108   {
109     if (expressions == null)
110     {
111       expressions = new EObjectContainmentEList<WMLValuedExpression>(WMLValuedExpression.class, this, WmlPackage.WML_MACRO_DEFINE__EXPRESSIONS);
112     }
113     return expressions;
114   }
115 
116   /**
117    * <!-- begin-user-doc -->
118    * <!-- end-user-doc -->
119    * @generated
120    */
getEndName()121   public String getEndName()
122   {
123     return endName;
124   }
125 
126   /**
127    * <!-- begin-user-doc -->
128    * <!-- end-user-doc -->
129    * @generated
130    */
setEndName(String newEndName)131   public void setEndName(String newEndName)
132   {
133     String oldEndName = endName;
134     endName = newEndName;
135     if (eNotificationRequired())
136       eNotify(new ENotificationImpl(this, Notification.SET, WmlPackage.WML_MACRO_DEFINE__END_NAME, oldEndName, endName));
137   }
138 
139   /**
140    * <!-- begin-user-doc -->
141    * <!-- end-user-doc -->
142    * @generated
143    */
144   @Override
eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)145   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
146   {
147     switch (featureID)
148     {
149       case WmlPackage.WML_MACRO_DEFINE__EXPRESSIONS:
150         return ((InternalEList<?>)getExpressions()).basicRemove(otherEnd, msgs);
151     }
152     return super.eInverseRemove(otherEnd, featureID, msgs);
153   }
154 
155   /**
156    * <!-- begin-user-doc -->
157    * <!-- end-user-doc -->
158    * @generated
159    */
160   @Override
eGet(int featureID, boolean resolve, boolean coreType)161   public Object eGet(int featureID, boolean resolve, boolean coreType)
162   {
163     switch (featureID)
164     {
165       case WmlPackage.WML_MACRO_DEFINE__EXPRESSIONS:
166         return getExpressions();
167       case WmlPackage.WML_MACRO_DEFINE__END_NAME:
168         return getEndName();
169     }
170     return super.eGet(featureID, resolve, coreType);
171   }
172 
173   /**
174    * <!-- begin-user-doc -->
175    * <!-- end-user-doc -->
176    * @generated
177    */
178   @SuppressWarnings("unchecked")
179   @Override
eSet(int featureID, Object newValue)180   public void eSet(int featureID, Object newValue)
181   {
182     switch (featureID)
183     {
184       case WmlPackage.WML_MACRO_DEFINE__EXPRESSIONS:
185         getExpressions().clear();
186         getExpressions().addAll((Collection<? extends WMLValuedExpression>)newValue);
187         return;
188       case WmlPackage.WML_MACRO_DEFINE__END_NAME:
189         setEndName((String)newValue);
190         return;
191     }
192     super.eSet(featureID, newValue);
193   }
194 
195   /**
196    * <!-- begin-user-doc -->
197    * <!-- end-user-doc -->
198    * @generated
199    */
200   @Override
eUnset(int featureID)201   public void eUnset(int featureID)
202   {
203     switch (featureID)
204     {
205       case WmlPackage.WML_MACRO_DEFINE__EXPRESSIONS:
206         getExpressions().clear();
207         return;
208       case WmlPackage.WML_MACRO_DEFINE__END_NAME:
209         setEndName(END_NAME_EDEFAULT);
210         return;
211     }
212     super.eUnset(featureID);
213   }
214 
215   /**
216    * <!-- begin-user-doc -->
217    * <!-- end-user-doc -->
218    * @generated
219    */
220   @Override
eIsSet(int featureID)221   public boolean eIsSet(int featureID)
222   {
223     switch (featureID)
224     {
225       case WmlPackage.WML_MACRO_DEFINE__EXPRESSIONS:
226         return expressions != null && !expressions.isEmpty();
227       case WmlPackage.WML_MACRO_DEFINE__END_NAME:
228         return END_NAME_EDEFAULT == null ? endName != null : !END_NAME_EDEFAULT.equals(endName);
229     }
230     return super.eIsSet(featureID);
231   }
232 
233   /**
234    * <!-- begin-user-doc -->
235    * <!-- end-user-doc -->
236    * @generated
237    */
238   @Override
toString()239   public String toString()
240   {
241     if (eIsProxy()) return super.toString();
242 
243     StringBuffer result = new StringBuffer(super.toString());
244     result.append(" (endName: ");
245     result.append(endName);
246     result.append(')');
247     return result.toString();
248   }
249 
250 } //WMLMacroDefineImpl
251