1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package scheduler.configuration.impl; |
8 | |
9 | import de.uka.ipd.sdq.identifier.impl.IdentifierImpl; |
10 | |
11 | import java.util.Collection; |
12 | |
13 | import org.eclipse.emf.common.notify.Notification; |
14 | |
15 | import org.eclipse.emf.common.util.EList; |
16 | |
17 | import org.eclipse.emf.ecore.EClass; |
18 | |
19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
20 | |
21 | import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; |
22 | |
23 | import scheduler.configuration.ConfigurationPackage; |
24 | import scheduler.configuration.PriorityClass; |
25 | import scheduler.configuration.ProcessConfiguration; |
26 | |
27 | /** |
28 | * <!-- begin-user-doc --> |
29 | * An implementation of the model object '<em><b>Process Configuration</b></em>'. |
30 | * <!-- end-user-doc --> |
31 | * <p> |
32 | * The following features are implemented: |
33 | * <ul> |
34 | * <li>{@link scheduler.configuration.impl.ProcessConfigurationImpl#getPriority <em>Priority</em>}</li> |
35 | * <li>{@link scheduler.configuration.impl.ProcessConfigurationImpl#getReplicas <em>Replicas</em>}</li> |
36 | * <li>{@link scheduler.configuration.impl.ProcessConfigurationImpl#getName <em>Name</em>}</li> |
37 | * <li>{@link scheduler.configuration.impl.ProcessConfigurationImpl#getAffinityList <em>Affinity List</em>}</li> |
38 | * </ul> |
39 | * </p> |
40 | * |
41 | * @generated |
42 | */ |
43 | public class ProcessConfigurationImpl extends IdentifierImpl implements ProcessConfiguration { |
44 | /** |
45 | * The default value of the '{@link #getPriority() <em>Priority</em>}' attribute. |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @see #getPriority() |
49 | * @generated |
50 | * @ordered |
51 | */ |
52 | protected static final PriorityClass PRIORITY_EDEFAULT = PriorityClass.LOWEST; |
53 | |
54 | /** |
55 | * The cached value of the '{@link #getPriority() <em>Priority</em>}' attribute. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @see #getPriority() |
59 | * @generated |
60 | * @ordered |
61 | */ |
62 | protected PriorityClass priority = PRIORITY_EDEFAULT; |
63 | |
64 | /** |
65 | * The default value of the '{@link #getReplicas() <em>Replicas</em>}' attribute. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @see #getReplicas() |
69 | * @generated |
70 | * @ordered |
71 | */ |
72 | protected static final int REPLICAS_EDEFAULT = 1; |
73 | |
74 | /** |
75 | * The cached value of the '{@link #getReplicas() <em>Replicas</em>}' attribute. |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @see #getReplicas() |
79 | * @generated |
80 | * @ordered |
81 | */ |
82 | protected int replicas = REPLICAS_EDEFAULT; |
83 | |
84 | /** |
85 | * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @see #getName() |
89 | * @generated |
90 | * @ordered |
91 | */ |
92 | protected static final String NAME_EDEFAULT = null; |
93 | |
94 | /** |
95 | * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @see #getName() |
99 | * @generated |
100 | * @ordered |
101 | */ |
102 | protected String name = NAME_EDEFAULT; |
103 | |
104 | /** |
105 | * The cached value of the '{@link #getAffinityList() <em>Affinity List</em>}' attribute list. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @see #getAffinityList() |
109 | * @generated |
110 | * @ordered |
111 | */ |
112 | protected EList<Integer> affinityList; |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | protected ProcessConfigurationImpl() { |
120 | super(); |
121 | } |
122 | |
123 | /** |
124 | * <!-- begin-user-doc --> |
125 | * <!-- end-user-doc --> |
126 | * @generated |
127 | */ |
128 | @Override |
129 | protected EClass eStaticClass() { |
130 | return ConfigurationPackage.Literals.PROCESS_CONFIGURATION; |
131 | } |
132 | |
133 | /** |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | public PriorityClass getPriority() { |
139 | return priority; |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | public void setPriority(PriorityClass newPriority) { |
148 | PriorityClass oldPriority = priority; |
149 | priority = newPriority == null ? PRIORITY_EDEFAULT : newPriority; |
150 | if (eNotificationRequired()) |
151 | eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackage.PROCESS_CONFIGURATION__PRIORITY, oldPriority, priority)); |
152 | } |
153 | |
154 | /** |
155 | * <!-- begin-user-doc --> |
156 | * <!-- end-user-doc --> |
157 | * @generated |
158 | */ |
159 | public int getReplicas() { |
160 | return replicas; |
161 | } |
162 | |
163 | /** |
164 | * <!-- begin-user-doc --> |
165 | * <!-- end-user-doc --> |
166 | * @generated |
167 | */ |
168 | public void setReplicas(int newReplicas) { |
169 | int oldReplicas = replicas; |
170 | replicas = newReplicas; |
171 | if (eNotificationRequired()) |
172 | eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackage.PROCESS_CONFIGURATION__REPLICAS, oldReplicas, replicas)); |
173 | } |
174 | |
175 | /** |
176 | * <!-- begin-user-doc --> |
177 | * <!-- end-user-doc --> |
178 | * @generated |
179 | */ |
180 | public String getName() { |
181 | return name; |
182 | } |
183 | |
184 | /** |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated |
188 | */ |
189 | public void setName(String newName) { |
190 | String oldName = name; |
191 | name = newName; |
192 | if (eNotificationRequired()) |
193 | eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackage.PROCESS_CONFIGURATION__NAME, oldName, name)); |
194 | } |
195 | |
196 | /** |
197 | * <!-- begin-user-doc --> |
198 | * <!-- end-user-doc --> |
199 | * @generated |
200 | */ |
201 | public EList<Integer> getAffinityList() { |
202 | if (affinityList == null) { |
203 | affinityList = new EDataTypeUniqueEList<Integer>(Integer.class, this, ConfigurationPackage.PROCESS_CONFIGURATION__AFFINITY_LIST); |
204 | } |
205 | return affinityList; |
206 | } |
207 | |
208 | /** |
209 | * <!-- begin-user-doc --> |
210 | * <!-- end-user-doc --> |
211 | * @generated |
212 | */ |
213 | @Override |
214 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
215 | switch (featureID) { |
216 | case ConfigurationPackage.PROCESS_CONFIGURATION__PRIORITY: |
217 | return getPriority(); |
218 | case ConfigurationPackage.PROCESS_CONFIGURATION__REPLICAS: |
219 | return getReplicas(); |
220 | case ConfigurationPackage.PROCESS_CONFIGURATION__NAME: |
221 | return getName(); |
222 | case ConfigurationPackage.PROCESS_CONFIGURATION__AFFINITY_LIST: |
223 | return getAffinityList(); |
224 | } |
225 | return super.eGet(featureID, resolve, coreType); |
226 | } |
227 | |
228 | /** |
229 | * <!-- begin-user-doc --> |
230 | * <!-- end-user-doc --> |
231 | * @generated |
232 | */ |
233 | @SuppressWarnings("unchecked") |
234 | @Override |
235 | public void eSet(int featureID, Object newValue) { |
236 | switch (featureID) { |
237 | case ConfigurationPackage.PROCESS_CONFIGURATION__PRIORITY: |
238 | setPriority((PriorityClass)newValue); |
239 | return; |
240 | case ConfigurationPackage.PROCESS_CONFIGURATION__REPLICAS: |
241 | setReplicas((Integer)newValue); |
242 | return; |
243 | case ConfigurationPackage.PROCESS_CONFIGURATION__NAME: |
244 | setName((String)newValue); |
245 | return; |
246 | case ConfigurationPackage.PROCESS_CONFIGURATION__AFFINITY_LIST: |
247 | getAffinityList().clear(); |
248 | getAffinityList().addAll((Collection<? extends Integer>)newValue); |
249 | return; |
250 | } |
251 | super.eSet(featureID, newValue); |
252 | } |
253 | |
254 | /** |
255 | * <!-- begin-user-doc --> |
256 | * <!-- end-user-doc --> |
257 | * @generated |
258 | */ |
259 | @Override |
260 | public void eUnset(int featureID) { |
261 | switch (featureID) { |
262 | case ConfigurationPackage.PROCESS_CONFIGURATION__PRIORITY: |
263 | setPriority(PRIORITY_EDEFAULT); |
264 | return; |
265 | case ConfigurationPackage.PROCESS_CONFIGURATION__REPLICAS: |
266 | setReplicas(REPLICAS_EDEFAULT); |
267 | return; |
268 | case ConfigurationPackage.PROCESS_CONFIGURATION__NAME: |
269 | setName(NAME_EDEFAULT); |
270 | return; |
271 | case ConfigurationPackage.PROCESS_CONFIGURATION__AFFINITY_LIST: |
272 | getAffinityList().clear(); |
273 | return; |
274 | } |
275 | super.eUnset(featureID); |
276 | } |
277 | |
278 | /** |
279 | * <!-- begin-user-doc --> |
280 | * <!-- end-user-doc --> |
281 | * @generated |
282 | */ |
283 | @Override |
284 | public boolean eIsSet(int featureID) { |
285 | switch (featureID) { |
286 | case ConfigurationPackage.PROCESS_CONFIGURATION__PRIORITY: |
287 | return priority != PRIORITY_EDEFAULT; |
288 | case ConfigurationPackage.PROCESS_CONFIGURATION__REPLICAS: |
289 | return replicas != REPLICAS_EDEFAULT; |
290 | case ConfigurationPackage.PROCESS_CONFIGURATION__NAME: |
291 | return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
292 | case ConfigurationPackage.PROCESS_CONFIGURATION__AFFINITY_LIST: |
293 | return affinityList != null && !affinityList.isEmpty(); |
294 | } |
295 | return super.eIsSet(featureID); |
296 | } |
297 | |
298 | /** |
299 | * <!-- begin-user-doc --> |
300 | * <!-- end-user-doc --> |
301 | * @generated |
302 | */ |
303 | @Override |
304 | public String toString() { |
305 | if (eIsProxy()) return super.toString(); |
306 | |
307 | StringBuffer result = new StringBuffer(super.toString()); |
308 | result.append(" (priority: "); |
309 | result.append(priority); |
310 | result.append(", replicas: "); |
311 | result.append(replicas); |
312 | result.append(", name: "); |
313 | result.append(name); |
314 | result.append(", affinityList: "); |
315 | result.append(affinityList); |
316 | result.append(')'); |
317 | return result.toString(); |
318 | } |
319 | |
320 | } //ProcessConfigurationImpl |