1 | /** |
2 | * Copyright 2008, sdq.ipd.uka.de, U KA |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.simucomframework.simucomstatus.impl; |
7 | |
8 | import de.uka.ipd.sdq.simucomframework.simucomstatus.PassiveResource; |
9 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusPackage; |
10 | import de.uka.ipd.sdq.simucomframework.simucomstatus.WaitForAcquire; |
11 | |
12 | import java.util.Collection; |
13 | |
14 | import org.eclipse.emf.common.notify.Notification; |
15 | import org.eclipse.emf.common.notify.NotificationChain; |
16 | |
17 | import org.eclipse.emf.common.util.EList; |
18 | |
19 | import org.eclipse.emf.ecore.EClass; |
20 | import org.eclipse.emf.ecore.InternalEObject; |
21 | |
22 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
23 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
24 | |
25 | import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; |
26 | import org.eclipse.emf.ecore.util.InternalEList; |
27 | |
28 | /** |
29 | * <!-- begin-user-doc --> |
30 | * An implementation of the model object '<em><b>Passive Resource</b></em>'. |
31 | * <!-- end-user-doc --> |
32 | * <p> |
33 | * The following features are implemented: |
34 | * <ul> |
35 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.PassiveResourceImpl#getWaitingProcesses <em>Waiting Processes</em>}</li> |
36 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.PassiveResourceImpl#getInitialResourceCount <em>Initial Resource Count</em>}</li> |
37 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.PassiveResourceImpl#getResourcesAvailable <em>Resources Available</em>}</li> |
38 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.PassiveResourceImpl#getId <em>Id</em>}</li> |
39 | * </ul> |
40 | * </p> |
41 | * |
42 | * @generated |
43 | */ |
44 | public class PassiveResourceImpl extends EObjectImpl implements PassiveResource { |
45 | /** |
46 | * The cached value of the '{@link #getWaitingProcesses() <em>Waiting Processes</em>}' reference list. |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @see #getWaitingProcesses() |
50 | * @generated |
51 | * @ordered |
52 | */ |
53 | protected EList<WaitForAcquire> waitingProcesses; |
54 | |
55 | /** |
56 | * The default value of the '{@link #getInitialResourceCount() <em>Initial Resource Count</em>}' attribute. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @see #getInitialResourceCount() |
60 | * @generated |
61 | * @ordered |
62 | */ |
63 | protected static final double INITIAL_RESOURCE_COUNT_EDEFAULT = 0.0; |
64 | |
65 | /** |
66 | * The cached value of the '{@link #getInitialResourceCount() <em>Initial Resource Count</em>}' attribute. |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @see #getInitialResourceCount() |
70 | * @generated |
71 | * @ordered |
72 | */ |
73 | protected double initialResourceCount = INITIAL_RESOURCE_COUNT_EDEFAULT; |
74 | |
75 | /** |
76 | * The default value of the '{@link #getResourcesAvailable() <em>Resources Available</em>}' attribute. |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @see #getResourcesAvailable() |
80 | * @generated |
81 | * @ordered |
82 | */ |
83 | protected static final double RESOURCES_AVAILABLE_EDEFAULT = 0.0; |
84 | |
85 | /** |
86 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. |
87 | * <!-- begin-user-doc --> |
88 | * <!-- end-user-doc --> |
89 | * @see #getId() |
90 | * @generated |
91 | * @ordered |
92 | */ |
93 | protected static final String ID_EDEFAULT = null; |
94 | |
95 | /** |
96 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. |
97 | * <!-- begin-user-doc --> |
98 | * <!-- end-user-doc --> |
99 | * @see #getId() |
100 | * @generated |
101 | * @ordered |
102 | */ |
103 | protected String id = ID_EDEFAULT; |
104 | |
105 | /** |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | protected PassiveResourceImpl() { |
111 | super(); |
112 | } |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | @Override |
120 | protected EClass eStaticClass() { |
121 | return SimucomstatusPackage.Literals.PASSIVE_RESOURCE; |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | public EList<WaitForAcquire> getWaitingProcesses() { |
130 | if (waitingProcesses == null) { |
131 | waitingProcesses = new EObjectWithInverseResolvingEList<WaitForAcquire>(WaitForAcquire.class, this, SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES, SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE); |
132 | } |
133 | return waitingProcesses; |
134 | } |
135 | |
136 | /** |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | public double getInitialResourceCount() { |
142 | return initialResourceCount; |
143 | } |
144 | |
145 | /** |
146 | * <!-- begin-user-doc --> |
147 | * <!-- end-user-doc --> |
148 | * @generated |
149 | */ |
150 | public void setInitialResourceCount(double newInitialResourceCount) { |
151 | double oldInitialResourceCount = initialResourceCount; |
152 | initialResourceCount = newInitialResourceCount; |
153 | if (eNotificationRequired()) |
154 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.PASSIVE_RESOURCE__INITIAL_RESOURCE_COUNT, oldInitialResourceCount, initialResourceCount)); |
155 | } |
156 | |
157 | /** |
158 | * <!-- begin-user-doc --> |
159 | * <!-- end-user-doc --> |
160 | * @generated |
161 | */ |
162 | public double getResourcesAvailable() { |
163 | // TODO: implement this method to return the 'Resources Available' attribute |
164 | // Ensure that you remove @generated or mark it @generated NOT |
165 | throw new UnsupportedOperationException(); |
166 | } |
167 | |
168 | /** |
169 | * <!-- begin-user-doc --> |
170 | * <!-- end-user-doc --> |
171 | * @generated |
172 | */ |
173 | public void setResourcesAvailable(double newResourcesAvailable) { |
174 | // TODO: implement this method to set the 'Resources Available' attribute |
175 | // Ensure that you remove @generated or mark it @generated NOT |
176 | throw new UnsupportedOperationException(); |
177 | } |
178 | |
179 | /** |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | public String getId() { |
185 | return id; |
186 | } |
187 | |
188 | /** |
189 | * <!-- begin-user-doc --> |
190 | * <!-- end-user-doc --> |
191 | * @generated |
192 | */ |
193 | public void setId(String newId) { |
194 | String oldId = id; |
195 | id = newId; |
196 | if (eNotificationRequired()) |
197 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.PASSIVE_RESOURCE__ID, oldId, id)); |
198 | } |
199 | |
200 | /** |
201 | * <!-- begin-user-doc --> |
202 | * <!-- end-user-doc --> |
203 | * @generated |
204 | */ |
205 | @SuppressWarnings("unchecked") |
206 | @Override |
207 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
208 | switch (featureID) { |
209 | case SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES: |
210 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getWaitingProcesses()).basicAdd(otherEnd, msgs); |
211 | } |
212 | return super.eInverseAdd(otherEnd, featureID, msgs); |
213 | } |
214 | |
215 | /** |
216 | * <!-- begin-user-doc --> |
217 | * <!-- end-user-doc --> |
218 | * @generated |
219 | */ |
220 | @Override |
221 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
222 | switch (featureID) { |
223 | case SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES: |
224 | return ((InternalEList<?>)getWaitingProcesses()).basicRemove(otherEnd, msgs); |
225 | } |
226 | return super.eInverseRemove(otherEnd, featureID, msgs); |
227 | } |
228 | |
229 | /** |
230 | * <!-- begin-user-doc --> |
231 | * <!-- end-user-doc --> |
232 | * @generated |
233 | */ |
234 | @Override |
235 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
236 | switch (featureID) { |
237 | case SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES: |
238 | return getWaitingProcesses(); |
239 | case SimucomstatusPackage.PASSIVE_RESOURCE__INITIAL_RESOURCE_COUNT: |
240 | return new Double(getInitialResourceCount()); |
241 | case SimucomstatusPackage.PASSIVE_RESOURCE__RESOURCES_AVAILABLE: |
242 | return new Double(getResourcesAvailable()); |
243 | case SimucomstatusPackage.PASSIVE_RESOURCE__ID: |
244 | return getId(); |
245 | } |
246 | return super.eGet(featureID, resolve, coreType); |
247 | } |
248 | |
249 | /** |
250 | * <!-- begin-user-doc --> |
251 | * <!-- end-user-doc --> |
252 | * @generated |
253 | */ |
254 | @SuppressWarnings("unchecked") |
255 | @Override |
256 | public void eSet(int featureID, Object newValue) { |
257 | switch (featureID) { |
258 | case SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES: |
259 | getWaitingProcesses().clear(); |
260 | getWaitingProcesses().addAll((Collection<? extends WaitForAcquire>)newValue); |
261 | return; |
262 | case SimucomstatusPackage.PASSIVE_RESOURCE__INITIAL_RESOURCE_COUNT: |
263 | setInitialResourceCount(((Double)newValue).doubleValue()); |
264 | return; |
265 | case SimucomstatusPackage.PASSIVE_RESOURCE__RESOURCES_AVAILABLE: |
266 | setResourcesAvailable(((Double)newValue).doubleValue()); |
267 | return; |
268 | case SimucomstatusPackage.PASSIVE_RESOURCE__ID: |
269 | setId((String)newValue); |
270 | return; |
271 | } |
272 | super.eSet(featureID, newValue); |
273 | } |
274 | |
275 | /** |
276 | * <!-- begin-user-doc --> |
277 | * <!-- end-user-doc --> |
278 | * @generated |
279 | */ |
280 | @Override |
281 | public void eUnset(int featureID) { |
282 | switch (featureID) { |
283 | case SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES: |
284 | getWaitingProcesses().clear(); |
285 | return; |
286 | case SimucomstatusPackage.PASSIVE_RESOURCE__INITIAL_RESOURCE_COUNT: |
287 | setInitialResourceCount(INITIAL_RESOURCE_COUNT_EDEFAULT); |
288 | return; |
289 | case SimucomstatusPackage.PASSIVE_RESOURCE__RESOURCES_AVAILABLE: |
290 | setResourcesAvailable(RESOURCES_AVAILABLE_EDEFAULT); |
291 | return; |
292 | case SimucomstatusPackage.PASSIVE_RESOURCE__ID: |
293 | setId(ID_EDEFAULT); |
294 | return; |
295 | } |
296 | super.eUnset(featureID); |
297 | } |
298 | |
299 | /** |
300 | * <!-- begin-user-doc --> |
301 | * <!-- end-user-doc --> |
302 | * @generated |
303 | */ |
304 | @Override |
305 | public boolean eIsSet(int featureID) { |
306 | switch (featureID) { |
307 | case SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES: |
308 | return waitingProcesses != null && !waitingProcesses.isEmpty(); |
309 | case SimucomstatusPackage.PASSIVE_RESOURCE__INITIAL_RESOURCE_COUNT: |
310 | return initialResourceCount != INITIAL_RESOURCE_COUNT_EDEFAULT; |
311 | case SimucomstatusPackage.PASSIVE_RESOURCE__RESOURCES_AVAILABLE: |
312 | return getResourcesAvailable() != RESOURCES_AVAILABLE_EDEFAULT; |
313 | case SimucomstatusPackage.PASSIVE_RESOURCE__ID: |
314 | return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); |
315 | } |
316 | return super.eIsSet(featureID); |
317 | } |
318 | |
319 | /** |
320 | * <!-- begin-user-doc --> |
321 | * <!-- end-user-doc --> |
322 | * @generated |
323 | */ |
324 | @Override |
325 | public String toString() { |
326 | if (eIsProxy()) return super.toString(); |
327 | |
328 | StringBuffer result = new StringBuffer(super.toString()); |
329 | result.append(" (initialResourceCount: "); |
330 | result.append(initialResourceCount); |
331 | result.append(", id: "); |
332 | result.append(id); |
333 | result.append(')'); |
334 | return result.toString(); |
335 | } |
336 | |
337 | } //PassiveResourceImpl |