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 | |
15 | import de.uka.ipd.sdq.probfunction.ProbabilityDensityFunction; |
16 | import de.uka.ipd.sdq.spa.resourcemodel.ActiveResource; |
17 | import de.uka.ipd.sdq.spa.resourcemodel.ResourceModelPackage; |
18 | import de.uka.ipd.sdq.spa.resourcemodel.ResourceUsage; |
19 | |
20 | /** |
21 | * <!-- begin-user-doc --> |
22 | * An implementation of the model object '<em><b>Resource Usage</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.ResourceUsageImpl#getUsageTime <em>Usage Time</em>}</li> |
28 | * <li>{@link de.uka.ipd.sdq.spa.resourcemodel.impl.ResourceUsageImpl#getResource <em>Resource</em>}</li> |
29 | * </ul> |
30 | * </p> |
31 | * |
32 | * @generated |
33 | */ |
34 | public class ResourceUsageImpl extends AbstractResourceUsageImpl implements ResourceUsage { |
35 | /** |
36 | * The cached value of the '{@link #getUsageTime() <em>Usage Time</em>}' containment reference. |
37 | * <!-- begin-user-doc --> |
38 | * <!-- end-user-doc --> |
39 | * @see #getUsageTime() |
40 | * @generated |
41 | * @ordered |
42 | */ |
43 | protected ProbabilityDensityFunction usageTime = null; |
44 | |
45 | /** |
46 | * The cached value of the '{@link #getResource() <em>Resource</em>}' reference. |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @see #getResource() |
50 | * @generated |
51 | * @ordered |
52 | */ |
53 | protected ActiveResource resource = null; |
54 | |
55 | /** |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @generated |
59 | */ |
60 | protected ResourceUsageImpl() { |
61 | super(); |
62 | } |
63 | |
64 | /** |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @generated |
68 | */ |
69 | protected EClass eStaticClass() { |
70 | return ResourceModelPackage.Literals.RESOURCE_USAGE; |
71 | } |
72 | |
73 | /** |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @generated |
77 | */ |
78 | public ProbabilityDensityFunction getUsageTime() { |
79 | return usageTime; |
80 | } |
81 | |
82 | /** |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @generated |
86 | */ |
87 | public NotificationChain basicSetUsageTime(ProbabilityDensityFunction newUsageTime, NotificationChain msgs) { |
88 | ProbabilityDensityFunction oldUsageTime = usageTime; |
89 | usageTime = newUsageTime; |
90 | if (eNotificationRequired()) { |
91 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME, oldUsageTime, newUsageTime); |
92 | if (msgs == null) msgs = notification; else msgs.add(notification); |
93 | } |
94 | return msgs; |
95 | } |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | public void setUsageTime(ProbabilityDensityFunction newUsageTime) { |
103 | if (newUsageTime != usageTime) { |
104 | NotificationChain msgs = null; |
105 | if (usageTime != null) |
106 | msgs = ((InternalEObject)usageTime).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME, null, msgs); |
107 | if (newUsageTime != null) |
108 | msgs = ((InternalEObject)newUsageTime).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME, null, msgs); |
109 | msgs = basicSetUsageTime(newUsageTime, msgs); |
110 | if (msgs != null) msgs.dispatch(); |
111 | } |
112 | else if (eNotificationRequired()) |
113 | eNotify(new ENotificationImpl(this, Notification.SET, ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME, newUsageTime, newUsageTime)); |
114 | } |
115 | |
116 | /** |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | public ActiveResource getResource() { |
122 | if (resource != null && resource.eIsProxy()) { |
123 | InternalEObject oldResource = (InternalEObject)resource; |
124 | resource = (ActiveResource)eResolveProxy(oldResource); |
125 | if (resource != oldResource) { |
126 | if (eNotificationRequired()) |
127 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, ResourceModelPackage.RESOURCE_USAGE__RESOURCE, oldResource, resource)); |
128 | } |
129 | } |
130 | return resource; |
131 | } |
132 | |
133 | /** |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | public ActiveResource basicGetResource() { |
139 | return resource; |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | public void setResource(ActiveResource newResource) { |
148 | ActiveResource oldResource = resource; |
149 | resource = newResource; |
150 | if (eNotificationRequired()) |
151 | eNotify(new ENotificationImpl(this, Notification.SET, ResourceModelPackage.RESOURCE_USAGE__RESOURCE, oldResource, resource)); |
152 | } |
153 | |
154 | /** |
155 | * <!-- begin-user-doc --> |
156 | * <!-- end-user-doc --> |
157 | * @generated |
158 | */ |
159 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
160 | switch (featureID) { |
161 | case ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME: |
162 | return basicSetUsageTime(null, msgs); |
163 | } |
164 | return super.eInverseRemove(otherEnd, featureID, msgs); |
165 | } |
166 | |
167 | /** |
168 | * <!-- begin-user-doc --> |
169 | * <!-- end-user-doc --> |
170 | * @generated |
171 | */ |
172 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
173 | switch (featureID) { |
174 | case ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME: |
175 | return getUsageTime(); |
176 | case ResourceModelPackage.RESOURCE_USAGE__RESOURCE: |
177 | if (resolve) return getResource(); |
178 | return basicGetResource(); |
179 | } |
180 | return super.eGet(featureID, resolve, coreType); |
181 | } |
182 | |
183 | /** |
184 | * <!-- begin-user-doc --> |
185 | * <!-- end-user-doc --> |
186 | * @generated |
187 | */ |
188 | public void eSet(int featureID, Object newValue) { |
189 | switch (featureID) { |
190 | case ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME: |
191 | setUsageTime((ProbabilityDensityFunction)newValue); |
192 | return; |
193 | case ResourceModelPackage.RESOURCE_USAGE__RESOURCE: |
194 | setResource((ActiveResource)newValue); |
195 | return; |
196 | } |
197 | super.eSet(featureID, newValue); |
198 | } |
199 | |
200 | /** |
201 | * <!-- begin-user-doc --> |
202 | * <!-- end-user-doc --> |
203 | * @generated |
204 | */ |
205 | public void eUnset(int featureID) { |
206 | switch (featureID) { |
207 | case ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME: |
208 | setUsageTime((ProbabilityDensityFunction)null); |
209 | return; |
210 | case ResourceModelPackage.RESOURCE_USAGE__RESOURCE: |
211 | setResource((ActiveResource)null); |
212 | return; |
213 | } |
214 | super.eUnset(featureID); |
215 | } |
216 | |
217 | /** |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | public boolean eIsSet(int featureID) { |
223 | switch (featureID) { |
224 | case ResourceModelPackage.RESOURCE_USAGE__USAGE_TIME: |
225 | return usageTime != null; |
226 | case ResourceModelPackage.RESOURCE_USAGE__RESOURCE: |
227 | return resource != null; |
228 | } |
229 | return super.eIsSet(featureID); |
230 | } |
231 | |
232 | } //ResourceUsageImpl |