1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.pcm.designdecision.impl; |
8 | |
9 | import de.uka.ipd.sdq.pcm.designdecision.Candidate; |
10 | import de.uka.ipd.sdq.pcm.designdecision.Candidates; |
11 | import de.uka.ipd.sdq.pcm.designdecision.DecisionSpace; |
12 | import de.uka.ipd.sdq.pcm.designdecision.designdecisionPackage; |
13 | |
14 | import de.uka.ipd.sdq.pcm.designdecision.util.designdecisionValidator; |
15 | |
16 | import java.util.Collection; |
17 | import java.util.Map; |
18 | |
19 | import org.eclipse.emf.common.notify.Notification; |
20 | import org.eclipse.emf.common.notify.NotificationChain; |
21 | |
22 | import org.eclipse.emf.common.util.BasicDiagnostic; |
23 | import org.eclipse.emf.common.util.Diagnostic; |
24 | import org.eclipse.emf.common.util.DiagnosticChain; |
25 | import org.eclipse.emf.common.util.EList; |
26 | |
27 | import org.eclipse.emf.ecore.EClass; |
28 | import org.eclipse.emf.ecore.InternalEObject; |
29 | |
30 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
31 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
32 | |
33 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
34 | |
35 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
36 | import org.eclipse.emf.ecore.util.EObjectValidator; |
37 | import org.eclipse.emf.ecore.util.InternalEList; |
38 | |
39 | /** |
40 | * <!-- begin-user-doc --> |
41 | * An implementation of the model object '<em><b>Candidates</b></em>'. |
42 | * <!-- end-user-doc --> |
43 | * <p> |
44 | * The following features are implemented: |
45 | * <ul> |
46 | * <li>{@link de.uka.ipd.sdq.pcm.designdecision.impl.CandidatesImpl#getCandidate <em>Candidate</em>}</li> |
47 | * <li>{@link de.uka.ipd.sdq.pcm.designdecision.impl.CandidatesImpl#getProblem <em>Problem</em>}</li> |
48 | * </ul> |
49 | * </p> |
50 | * |
51 | * @generated |
52 | */ |
53 | public class CandidatesImpl extends EObjectImpl implements Candidates { |
54 | /** |
55 | * The cached value of the '{@link #getCandidate() <em>Candidate</em>}' containment reference list. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @see #getCandidate() |
59 | * @generated |
60 | * @ordered |
61 | */ |
62 | protected EList<Candidate> candidate; |
63 | |
64 | /** |
65 | * The cached value of the '{@link #getProblem() <em>Problem</em>}' reference. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @see #getProblem() |
69 | * @generated |
70 | * @ordered |
71 | */ |
72 | protected DecisionSpace problem; |
73 | |
74 | /** |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @generated |
78 | */ |
79 | protected CandidatesImpl() { |
80 | super(); |
81 | } |
82 | |
83 | /** |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @generated |
87 | */ |
88 | @Override |
89 | protected EClass eStaticClass() { |
90 | return designdecisionPackage.Literals.CANDIDATES; |
91 | } |
92 | |
93 | /** |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | public EList<Candidate> getCandidate() { |
99 | if (candidate == null) { |
100 | candidate = new EObjectContainmentEList<Candidate>(Candidate.class, this, designdecisionPackage.CANDIDATES__CANDIDATE); |
101 | } |
102 | return candidate; |
103 | } |
104 | |
105 | /** |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | public DecisionSpace getProblem() { |
111 | if (problem != null && problem.eIsProxy()) { |
112 | InternalEObject oldProblem = (InternalEObject)problem; |
113 | problem = (DecisionSpace)eResolveProxy(oldProblem); |
114 | if (problem != oldProblem) { |
115 | if (eNotificationRequired()) |
116 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, designdecisionPackage.CANDIDATES__PROBLEM, oldProblem, problem)); |
117 | } |
118 | } |
119 | return problem; |
120 | } |
121 | |
122 | /** |
123 | * <!-- begin-user-doc --> |
124 | * <!-- end-user-doc --> |
125 | * @generated |
126 | */ |
127 | public DecisionSpace basicGetProblem() { |
128 | return problem; |
129 | } |
130 | |
131 | /** |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | public void setProblem(DecisionSpace newProblem) { |
137 | DecisionSpace oldProblem = problem; |
138 | problem = newProblem; |
139 | if (eNotificationRequired()) |
140 | eNotify(new ENotificationImpl(this, Notification.SET, designdecisionPackage.CANDIDATES__PROBLEM, oldProblem, problem)); |
141 | } |
142 | |
143 | /** |
144 | * <!-- begin-user-doc --> |
145 | * <!-- end-user-doc --> |
146 | * @generated |
147 | */ |
148 | public boolean numberOfChoicesMustEqualNumberOfDecisions(DiagnosticChain diagnostics, Map<Object, Object> context) { |
149 | // TODO: implement this method |
150 | // -> specify the condition that violates the invariant |
151 | // -> verify the details of the diagnostic, including severity and message |
152 | // Ensure that you remove @generated or mark it @generated NOT |
153 | if (false) { |
154 | if (diagnostics != null) { |
155 | diagnostics.add |
156 | (new BasicDiagnostic |
157 | (Diagnostic.ERROR, |
158 | designdecisionValidator.DIAGNOSTIC_SOURCE, |
159 | designdecisionValidator.CANDIDATES__NUMBER_OF_CHOICES_MUST_EQUAL_NUMBER_OF_DECISIONS, |
160 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "numberOfChoicesMustEqualNumberOfDecisions", EObjectValidator.getObjectLabel(this, context) }), |
161 | new Object [] { this })); |
162 | } |
163 | return false; |
164 | } |
165 | return true; |
166 | } |
167 | |
168 | /** |
169 | * <!-- begin-user-doc --> |
170 | * <!-- end-user-doc --> |
171 | * @generated |
172 | */ |
173 | @Override |
174 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
175 | switch (featureID) { |
176 | case designdecisionPackage.CANDIDATES__CANDIDATE: |
177 | return ((InternalEList<?>)getCandidate()).basicRemove(otherEnd, msgs); |
178 | } |
179 | return super.eInverseRemove(otherEnd, featureID, msgs); |
180 | } |
181 | |
182 | /** |
183 | * <!-- begin-user-doc --> |
184 | * <!-- end-user-doc --> |
185 | * @generated |
186 | */ |
187 | @Override |
188 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
189 | switch (featureID) { |
190 | case designdecisionPackage.CANDIDATES__CANDIDATE: |
191 | return getCandidate(); |
192 | case designdecisionPackage.CANDIDATES__PROBLEM: |
193 | if (resolve) return getProblem(); |
194 | return basicGetProblem(); |
195 | } |
196 | return super.eGet(featureID, resolve, coreType); |
197 | } |
198 | |
199 | /** |
200 | * <!-- begin-user-doc --> |
201 | * <!-- end-user-doc --> |
202 | * @generated |
203 | */ |
204 | @SuppressWarnings("unchecked") |
205 | @Override |
206 | public void eSet(int featureID, Object newValue) { |
207 | switch (featureID) { |
208 | case designdecisionPackage.CANDIDATES__CANDIDATE: |
209 | getCandidate().clear(); |
210 | getCandidate().addAll((Collection<? extends Candidate>)newValue); |
211 | return; |
212 | case designdecisionPackage.CANDIDATES__PROBLEM: |
213 | setProblem((DecisionSpace)newValue); |
214 | return; |
215 | } |
216 | super.eSet(featureID, newValue); |
217 | } |
218 | |
219 | /** |
220 | * <!-- begin-user-doc --> |
221 | * <!-- end-user-doc --> |
222 | * @generated |
223 | */ |
224 | @Override |
225 | public void eUnset(int featureID) { |
226 | switch (featureID) { |
227 | case designdecisionPackage.CANDIDATES__CANDIDATE: |
228 | getCandidate().clear(); |
229 | return; |
230 | case designdecisionPackage.CANDIDATES__PROBLEM: |
231 | setProblem((DecisionSpace)null); |
232 | return; |
233 | } |
234 | super.eUnset(featureID); |
235 | } |
236 | |
237 | /** |
238 | * <!-- begin-user-doc --> |
239 | * <!-- end-user-doc --> |
240 | * @generated |
241 | */ |
242 | @Override |
243 | public boolean eIsSet(int featureID) { |
244 | switch (featureID) { |
245 | case designdecisionPackage.CANDIDATES__CANDIDATE: |
246 | return candidate != null && !candidate.isEmpty(); |
247 | case designdecisionPackage.CANDIDATES__PROBLEM: |
248 | return problem != null; |
249 | } |
250 | return super.eIsSet(featureID); |
251 | } |
252 | |
253 | } //CandidatesImpl |