1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.probfunction.impl; |
8 | |
9 | import java.util.Collection; |
10 | |
11 | import org.eclipse.emf.common.notify.Notification; |
12 | import org.eclipse.emf.common.notify.NotificationChain; |
13 | import org.eclipse.emf.common.util.EList; |
14 | import org.eclipse.emf.ecore.EClass; |
15 | import org.eclipse.emf.ecore.InternalEObject; |
16 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
17 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
18 | import org.eclipse.emf.ecore.util.InternalEList; |
19 | |
20 | import de.uka.ipd.sdq.probfunction.Complex; |
21 | import de.uka.ipd.sdq.probfunction.ProbfunctionPackage; |
22 | import de.uka.ipd.sdq.probfunction.SamplePDF; |
23 | |
24 | /** |
25 | * <!-- begin-user-doc --> |
26 | * An implementation of the model object '<em><b>Sample PDF</b></em>'. |
27 | * <!-- end-user-doc --> |
28 | * <p> |
29 | * The following features are implemented: |
30 | * <ul> |
31 | * <li>{@link de.uka.ipd.sdq.probfunction.impl.SamplePDFImpl#getDistance <em>Distance</em>}</li> |
32 | * <li>{@link de.uka.ipd.sdq.probfunction.impl.SamplePDFImpl#getValues <em>Values</em>}</li> |
33 | * </ul> |
34 | * </p> |
35 | * |
36 | * @generated |
37 | */ |
38 | public class SamplePDFImpl extends ProbabilityDensityFunctionImpl implements SamplePDF { |
39 | /** |
40 | * <!-- begin-user-doc --> |
41 | * <!-- end-user-doc --> |
42 | * @generated |
43 | */ |
44 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
45 | |
46 | /** |
47 | * The default value of the '{@link #getDistance() <em>Distance</em>}' attribute. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @see #getDistance() |
51 | * @generated |
52 | * @ordered |
53 | */ |
54 | protected static final double DISTANCE_EDEFAULT = 0.0; |
55 | |
56 | /** |
57 | * The cached value of the '{@link #getDistance() <em>Distance</em>}' attribute. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @see #getDistance() |
61 | * @generated |
62 | * @ordered |
63 | */ |
64 | protected double distance = DISTANCE_EDEFAULT; |
65 | |
66 | /** |
67 | * The cached value of the '{@link #getValues() <em>Values</em>}' containment reference list. |
68 | * <!-- begin-user-doc --> |
69 | * <!-- end-user-doc --> |
70 | * @see #getValues() |
71 | * @generated |
72 | * @ordered |
73 | */ |
74 | protected EList<Complex> values; |
75 | |
76 | /** |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @generated |
80 | */ |
81 | protected SamplePDFImpl() { |
82 | super(); |
83 | } |
84 | |
85 | /** |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @generated |
89 | */ |
90 | @Override |
91 | protected EClass eStaticClass() { |
92 | return ProbfunctionPackage.Literals.SAMPLE_PDF; |
93 | } |
94 | |
95 | /** |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @generated |
99 | */ |
100 | public double getDistance() { |
101 | return distance; |
102 | } |
103 | |
104 | /** |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | public void setDistance(double newDistance) { |
110 | double oldDistance = distance; |
111 | distance = newDistance; |
112 | if (eNotificationRequired()) |
113 | eNotify(new ENotificationImpl(this, Notification.SET, ProbfunctionPackage.SAMPLE_PDF__DISTANCE, oldDistance, distance)); |
114 | } |
115 | |
116 | /** |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | public EList<Complex> getValues() { |
122 | if (values == null) { |
123 | values = new EObjectContainmentEList<Complex>(Complex.class, this, ProbfunctionPackage.SAMPLE_PDF__VALUES); |
124 | } |
125 | return values; |
126 | } |
127 | |
128 | /** |
129 | * <!-- begin-user-doc --> |
130 | * <!-- end-user-doc --> |
131 | * @generated |
132 | */ |
133 | @Override |
134 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
135 | switch (featureID) { |
136 | case ProbfunctionPackage.SAMPLE_PDF__VALUES: |
137 | return ((InternalEList<?>)getValues()).basicRemove(otherEnd, msgs); |
138 | } |
139 | return super.eInverseRemove(otherEnd, featureID, msgs); |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | @Override |
148 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
149 | switch (featureID) { |
150 | case ProbfunctionPackage.SAMPLE_PDF__DISTANCE: |
151 | return getDistance(); |
152 | case ProbfunctionPackage.SAMPLE_PDF__VALUES: |
153 | return getValues(); |
154 | } |
155 | return super.eGet(featureID, resolve, coreType); |
156 | } |
157 | |
158 | /** |
159 | * <!-- begin-user-doc --> |
160 | * <!-- end-user-doc --> |
161 | * @generated |
162 | */ |
163 | @SuppressWarnings("unchecked") |
164 | @Override |
165 | public void eSet(int featureID, Object newValue) { |
166 | switch (featureID) { |
167 | case ProbfunctionPackage.SAMPLE_PDF__DISTANCE: |
168 | setDistance((Double)newValue); |
169 | return; |
170 | case ProbfunctionPackage.SAMPLE_PDF__VALUES: |
171 | getValues().clear(); |
172 | getValues().addAll((Collection<? extends Complex>)newValue); |
173 | return; |
174 | } |
175 | super.eSet(featureID, newValue); |
176 | } |
177 | |
178 | /** |
179 | * <!-- begin-user-doc --> |
180 | * <!-- end-user-doc --> |
181 | * @generated |
182 | */ |
183 | @Override |
184 | public void eUnset(int featureID) { |
185 | switch (featureID) { |
186 | case ProbfunctionPackage.SAMPLE_PDF__DISTANCE: |
187 | setDistance(DISTANCE_EDEFAULT); |
188 | return; |
189 | case ProbfunctionPackage.SAMPLE_PDF__VALUES: |
190 | getValues().clear(); |
191 | return; |
192 | } |
193 | super.eUnset(featureID); |
194 | } |
195 | |
196 | /** |
197 | * <!-- begin-user-doc --> |
198 | * <!-- end-user-doc --> |
199 | * @generated |
200 | */ |
201 | @Override |
202 | public boolean eIsSet(int featureID) { |
203 | switch (featureID) { |
204 | case ProbfunctionPackage.SAMPLE_PDF__DISTANCE: |
205 | return distance != DISTANCE_EDEFAULT; |
206 | case ProbfunctionPackage.SAMPLE_PDF__VALUES: |
207 | return values != null && !values.isEmpty(); |
208 | } |
209 | return super.eIsSet(featureID); |
210 | } |
211 | |
212 | /** |
213 | * <!-- begin-user-doc --> |
214 | * <!-- end-user-doc --> |
215 | * @generated |
216 | */ |
217 | @Override |
218 | public String toString() { |
219 | if (eIsProxy()) return super.toString(); |
220 | |
221 | StringBuffer result = new StringBuffer(super.toString()); |
222 | result.append(" (distance: "); |
223 | result.append(distance); |
224 | result.append(')'); |
225 | return result.toString(); |
226 | } |
227 | |
228 | } //SamplePDFImpl |