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