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