1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.spa.resourcemodel.impl; |
8 | |
9 | import org.eclipse.emf.common.notify.Notification; |
10 | import org.eclipse.emf.common.notify.NotificationChain; |
11 | import org.eclipse.emf.ecore.EClass; |
12 | import org.eclipse.emf.ecore.InternalEObject; |
13 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
14 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
15 | |
16 | import de.uka.ipd.sdq.spa.resourcemodel.AbstractResourceUsage; |
17 | import de.uka.ipd.sdq.spa.resourcemodel.Option; |
18 | import de.uka.ipd.sdq.spa.resourcemodel.ResourceModelPackage; |
19 | |
20 | /** |
21 | * <!-- begin-user-doc --> |
22 | * An implementation of the model object '<em><b>Option</b></em>'. |
23 | * <!-- end-user-doc --> |
24 | * <p> |
25 | * The following features are implemented: |
26 | * <ul> |
27 | * <li>{@link de.uka.ipd.sdq.spa.resourcemodel.impl.OptionImpl#getProbability <em>Probability</em>}</li> |
28 | * <li>{@link de.uka.ipd.sdq.spa.resourcemodel.impl.OptionImpl#getResourceUsage <em>Resource Usage</em>}</li> |
29 | * </ul> |
30 | * </p> |
31 | * |
32 | * @generated |
33 | */ |
34 | public class OptionImpl extends EObjectImpl implements Option { |
35 | /** |
36 | * The default value of the '{@link #getProbability() <em>Probability</em>}' attribute. |
37 | * <!-- begin-user-doc --> |
38 | * <!-- end-user-doc --> |
39 | * @see #getProbability() |
40 | * @generated |
41 | * @ordered |
42 | */ |
43 | protected static final double PROBABILITY_EDEFAULT = 0.0; |
44 | |
45 | /** |
46 | * The cached value of the '{@link #getProbability() <em>Probability</em>}' attribute. |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @see #getProbability() |
50 | * @generated |
51 | * @ordered |
52 | */ |
53 | protected double probability = PROBABILITY_EDEFAULT; |
54 | |
55 | /** |
56 | * The cached value of the '{@link #getResourceUsage() <em>Resource Usage</em>}' containment reference. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @see #getResourceUsage() |
60 | * @generated |
61 | * @ordered |
62 | */ |
63 | protected AbstractResourceUsage resourceUsage = null; |
64 | |
65 | /** |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @generated |
69 | */ |
70 | protected OptionImpl() { |
71 | super(); |
72 | } |
73 | |
74 | /** |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @generated |
78 | */ |
79 | protected EClass eStaticClass() { |
80 | return ResourceModelPackage.Literals.OPTION; |
81 | } |
82 | |
83 | /** |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @generated |
87 | */ |
88 | public double getProbability() { |
89 | return probability; |
90 | } |
91 | |
92 | /** |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | public void setProbability(double newProbability) { |
98 | double oldProbability = probability; |
99 | probability = newProbability; |
100 | if (eNotificationRequired()) |
101 | eNotify(new ENotificationImpl(this, Notification.SET, ResourceModelPackage.OPTION__PROBABILITY, oldProbability, probability)); |
102 | } |
103 | |
104 | /** |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | public AbstractResourceUsage getResourceUsage() { |
110 | return resourceUsage; |
111 | } |
112 | |
113 | /** |
114 | * <!-- begin-user-doc --> |
115 | * <!-- end-user-doc --> |
116 | * @generated |
117 | */ |
118 | public NotificationChain basicSetResourceUsage(AbstractResourceUsage newResourceUsage, NotificationChain msgs) { |
119 | AbstractResourceUsage oldResourceUsage = resourceUsage; |
120 | resourceUsage = newResourceUsage; |
121 | if (eNotificationRequired()) { |
122 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ResourceModelPackage.OPTION__RESOURCE_USAGE, oldResourceUsage, newResourceUsage); |
123 | if (msgs == null) msgs = notification; else msgs.add(notification); |
124 | } |
125 | return msgs; |
126 | } |
127 | |
128 | /** |
129 | * <!-- begin-user-doc --> |
130 | * <!-- end-user-doc --> |
131 | * @generated |
132 | */ |
133 | public void setResourceUsage(AbstractResourceUsage newResourceUsage) { |
134 | if (newResourceUsage != resourceUsage) { |
135 | NotificationChain msgs = null; |
136 | if (resourceUsage != null) |
137 | msgs = ((InternalEObject)resourceUsage).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ResourceModelPackage.OPTION__RESOURCE_USAGE, null, msgs); |
138 | if (newResourceUsage != null) |
139 | msgs = ((InternalEObject)newResourceUsage).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ResourceModelPackage.OPTION__RESOURCE_USAGE, null, msgs); |
140 | msgs = basicSetResourceUsage(newResourceUsage, msgs); |
141 | if (msgs != null) msgs.dispatch(); |
142 | } |
143 | else if (eNotificationRequired()) |
144 | eNotify(new ENotificationImpl(this, Notification.SET, ResourceModelPackage.OPTION__RESOURCE_USAGE, newResourceUsage, newResourceUsage)); |
145 | } |
146 | |
147 | /** |
148 | * <!-- begin-user-doc --> |
149 | * <!-- end-user-doc --> |
150 | * @generated |
151 | */ |
152 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
153 | switch (featureID) { |
154 | case ResourceModelPackage.OPTION__RESOURCE_USAGE: |
155 | return basicSetResourceUsage(null, msgs); |
156 | } |
157 | return super.eInverseRemove(otherEnd, featureID, msgs); |
158 | } |
159 | |
160 | /** |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
166 | switch (featureID) { |
167 | case ResourceModelPackage.OPTION__PROBABILITY: |
168 | return new Double(getProbability()); |
169 | case ResourceModelPackage.OPTION__RESOURCE_USAGE: |
170 | return getResourceUsage(); |
171 | } |
172 | return super.eGet(featureID, resolve, coreType); |
173 | } |
174 | |
175 | /** |
176 | * <!-- begin-user-doc --> |
177 | * <!-- end-user-doc --> |
178 | * @generated |
179 | */ |
180 | public void eSet(int featureID, Object newValue) { |
181 | switch (featureID) { |
182 | case ResourceModelPackage.OPTION__PROBABILITY: |
183 | setProbability(((Double)newValue).doubleValue()); |
184 | return; |
185 | case ResourceModelPackage.OPTION__RESOURCE_USAGE: |
186 | setResourceUsage((AbstractResourceUsage)newValue); |
187 | return; |
188 | } |
189 | super.eSet(featureID, newValue); |
190 | } |
191 | |
192 | /** |
193 | * <!-- begin-user-doc --> |
194 | * <!-- end-user-doc --> |
195 | * @generated |
196 | */ |
197 | public void eUnset(int featureID) { |
198 | switch (featureID) { |
199 | case ResourceModelPackage.OPTION__PROBABILITY: |
200 | setProbability(PROBABILITY_EDEFAULT); |
201 | return; |
202 | case ResourceModelPackage.OPTION__RESOURCE_USAGE: |
203 | setResourceUsage((AbstractResourceUsage)null); |
204 | return; |
205 | } |
206 | super.eUnset(featureID); |
207 | } |
208 | |
209 | /** |
210 | * <!-- begin-user-doc --> |
211 | * <!-- end-user-doc --> |
212 | * @generated |
213 | */ |
214 | public boolean eIsSet(int featureID) { |
215 | switch (featureID) { |
216 | case ResourceModelPackage.OPTION__PROBABILITY: |
217 | return probability != PROBABILITY_EDEFAULT; |
218 | case ResourceModelPackage.OPTION__RESOURCE_USAGE: |
219 | return resourceUsage != null; |
220 | } |
221 | return super.eIsSet(featureID); |
222 | } |
223 | |
224 | /** |
225 | * <!-- begin-user-doc --> |
226 | * <!-- end-user-doc --> |
227 | * @generated |
228 | */ |
229 | public String toString() { |
230 | if (eIsProxy()) return super.toString(); |
231 | |
232 | StringBuffer result = new StringBuffer(super.toString()); |
233 | result.append(" (probability: "); |
234 | result.append(probability); |
235 | result.append(')'); |
236 | return result.toString(); |
237 | } |
238 | |
239 | } //OptionImpl |