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.ProbabilityMassFunction; |
21 | import de.uka.ipd.sdq.probfunction.ProbfunctionPackage; |
22 | import de.uka.ipd.sdq.probfunction.Sample; |
23 | |
24 | /** |
25 | * <!-- begin-user-doc --> |
26 | * An implementation of the model object '<em><b>Probability Mass Function</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.ProbabilityMassFunctionImpl#getSamples <em>Samples</em>}</li> |
32 | * <li>{@link de.uka.ipd.sdq.probfunction.impl.ProbabilityMassFunctionImpl#isOrderedDomain <em>Ordered Domain</em>}</li> |
33 | * </ul> |
34 | * </p> |
35 | * |
36 | * @generated |
37 | */ |
38 | public class ProbabilityMassFunctionImpl extends ProbabilityFunctionImpl implements ProbabilityMassFunction { |
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 cached value of the '{@link #getSamples() <em>Samples</em>}' containment reference list. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @see #getSamples() |
51 | * @generated |
52 | * @ordered |
53 | */ |
54 | protected EList<Sample> samples; |
55 | |
56 | /** |
57 | * The default value of the '{@link #isOrderedDomain() <em>Ordered Domain</em>}' attribute. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @see #isOrderedDomain() |
61 | * @generated |
62 | * @ordered |
63 | */ |
64 | protected static final boolean ORDERED_DOMAIN_EDEFAULT = false; |
65 | |
66 | /** |
67 | * The cached value of the '{@link #isOrderedDomain() <em>Ordered Domain</em>}' attribute. |
68 | * <!-- begin-user-doc --> |
69 | * <!-- end-user-doc --> |
70 | * @see #isOrderedDomain() |
71 | * @generated |
72 | * @ordered |
73 | */ |
74 | protected boolean orderedDomain = ORDERED_DOMAIN_EDEFAULT; |
75 | |
76 | /** |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @generated |
80 | */ |
81 | protected ProbabilityMassFunctionImpl() { |
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.PROBABILITY_MASS_FUNCTION; |
93 | } |
94 | |
95 | /** |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @generated |
99 | */ |
100 | public EList<Sample> getSamples() { |
101 | if (samples == null) { |
102 | samples = new EObjectContainmentEList<Sample>(Sample.class, this, ProbfunctionPackage.PROBABILITY_MASS_FUNCTION__SAMPLES); |
103 | } |
104 | return samples; |
105 | } |
106 | |
107 | /** |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | public boolean isOrderedDomain() { |
113 | return orderedDomain; |
114 | } |
115 | |
116 | /** |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | public void setOrderedDomain(boolean newOrderedDomain) { |
122 | boolean oldOrderedDomain = orderedDomain; |
123 | orderedDomain = newOrderedDomain; |
124 | if (eNotificationRequired()) |
125 | eNotify(new ENotificationImpl(this, Notification.SET, ProbfunctionPackage.PROBABILITY_MASS_FUNCTION__ORDERED_DOMAIN, oldOrderedDomain, orderedDomain)); |
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.PROBABILITY_MASS_FUNCTION__SAMPLES: |
137 | return ((InternalEList<?>)getSamples()).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.PROBABILITY_MASS_FUNCTION__SAMPLES: |
151 | return getSamples(); |
152 | case ProbfunctionPackage.PROBABILITY_MASS_FUNCTION__ORDERED_DOMAIN: |
153 | return isOrderedDomain(); |
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.PROBABILITY_MASS_FUNCTION__SAMPLES: |
168 | getSamples().clear(); |
169 | getSamples().addAll((Collection<? extends Sample>)newValue); |
170 | return; |
171 | case ProbfunctionPackage.PROBABILITY_MASS_FUNCTION__ORDERED_DOMAIN: |
172 | setOrderedDomain((Boolean)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.PROBABILITY_MASS_FUNCTION__SAMPLES: |
187 | getSamples().clear(); |
188 | return; |
189 | case ProbfunctionPackage.PROBABILITY_MASS_FUNCTION__ORDERED_DOMAIN: |
190 | setOrderedDomain(ORDERED_DOMAIN_EDEFAULT); |
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.PROBABILITY_MASS_FUNCTION__SAMPLES: |
205 | return samples != null && !samples.isEmpty(); |
206 | case ProbfunctionPackage.PROBABILITY_MASS_FUNCTION__ORDERED_DOMAIN: |
207 | return orderedDomain != ORDERED_DOMAIN_EDEFAULT; |
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(" (orderedDomain: "); |
223 | result.append(orderedDomain); |
224 | result.append(')'); |
225 | return result.toString(); |
226 | } |
227 | |
228 | } //ProbabilityMassFunctionImpl |