1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featuremodel.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.EObject; |
16 | import org.eclipse.emf.ecore.InternalEObject; |
17 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
18 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
19 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
20 | import org.eclipse.emf.ecore.util.InternalEList; |
21 | |
22 | import de.uka.ipd.sdq.featuremodel.Constraint; |
23 | import de.uka.ipd.sdq.featuremodel.Feature; |
24 | import de.uka.ipd.sdq.featuremodel.FeatureDiagram; |
25 | import de.uka.ipd.sdq.featuremodel.featuremodelPackage; |
26 | |
27 | /** |
28 | * <!-- begin-user-doc --> |
29 | * An implementation of the model object '<em><b>Feature Diagram</b></em>'. |
30 | * <!-- end-user-doc --> |
31 | * <p> |
32 | * The following features are implemented: |
33 | * <ul> |
34 | * <li>{@link de.uka.ipd.sdq.featuremodel.impl.FeatureDiagramImpl#getRootFeature <em>Root Feature</em>}</li> |
35 | * <li>{@link de.uka.ipd.sdq.featuremodel.impl.FeatureDiagramImpl#getConstraints <em>Constraints</em>}</li> |
36 | * <li>{@link de.uka.ipd.sdq.featuremodel.impl.FeatureDiagramImpl#getAnnotatableElement <em>Annotatable Element</em>}</li> |
37 | * </ul> |
38 | * </p> |
39 | * |
40 | * @generated |
41 | */ |
42 | public class FeatureDiagramImpl extends NamedElementImpl implements FeatureDiagram { |
43 | /** |
44 | * The cached value of the '{@link #getRootFeature() <em>Root Feature</em>}' containment reference. |
45 | * <!-- begin-user-doc --> |
46 | * <!-- end-user-doc --> |
47 | * @see #getRootFeature() |
48 | * @generated |
49 | * @ordered |
50 | */ |
51 | protected Feature rootFeature; |
52 | |
53 | /** |
54 | * The cached value of the '{@link #getConstraints() <em>Constraints</em>}' containment reference list. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @see #getConstraints() |
58 | * @generated |
59 | * @ordered |
60 | */ |
61 | protected EList<Constraint> constraints; |
62 | |
63 | /** |
64 | * The cached value of the '{@link #getAnnotatableElement() <em>Annotatable Element</em>}' reference list. |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @see #getAnnotatableElement() |
68 | * @generated |
69 | * @ordered |
70 | */ |
71 | protected EList<EObject> annotatableElement; |
72 | |
73 | /** |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @generated |
77 | */ |
78 | protected FeatureDiagramImpl() { |
79 | super(); |
80 | } |
81 | |
82 | /** |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @generated |
86 | */ |
87 | @Override |
88 | protected EClass eStaticClass() { |
89 | return featuremodelPackage.Literals.FEATURE_DIAGRAM; |
90 | } |
91 | |
92 | /** |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | public Feature getRootFeature() { |
98 | return rootFeature; |
99 | } |
100 | |
101 | /** |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | public NotificationChain basicSetRootFeature(Feature newRootFeature, NotificationChain msgs) { |
107 | Feature oldRootFeature = rootFeature; |
108 | rootFeature = newRootFeature; |
109 | if (eNotificationRequired()) { |
110 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE, oldRootFeature, newRootFeature); |
111 | if (msgs == null) msgs = notification; else msgs.add(notification); |
112 | } |
113 | return msgs; |
114 | } |
115 | |
116 | /** |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | public void setRootFeature(Feature newRootFeature) { |
122 | if (newRootFeature != rootFeature) { |
123 | NotificationChain msgs = null; |
124 | if (rootFeature != null) |
125 | msgs = ((InternalEObject)rootFeature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE, null, msgs); |
126 | if (newRootFeature != null) |
127 | msgs = ((InternalEObject)newRootFeature).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE, null, msgs); |
128 | msgs = basicSetRootFeature(newRootFeature, msgs); |
129 | if (msgs != null) msgs.dispatch(); |
130 | } |
131 | else if (eNotificationRequired()) |
132 | eNotify(new ENotificationImpl(this, Notification.SET, featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE, newRootFeature, newRootFeature)); |
133 | } |
134 | |
135 | /** |
136 | * <!-- begin-user-doc --> |
137 | * <!-- end-user-doc --> |
138 | * @generated |
139 | */ |
140 | public EList<Constraint> getConstraints() { |
141 | if (constraints == null) { |
142 | constraints = new EObjectContainmentEList<Constraint>(Constraint.class, this, featuremodelPackage.FEATURE_DIAGRAM__CONSTRAINTS); |
143 | } |
144 | return constraints; |
145 | } |
146 | |
147 | /** |
148 | * <!-- begin-user-doc --> |
149 | * <!-- end-user-doc --> |
150 | * @generated |
151 | */ |
152 | public EList<EObject> getAnnotatableElement() { |
153 | if (annotatableElement == null) { |
154 | annotatableElement = new EObjectResolvingEList<EObject>(EObject.class, this, featuremodelPackage.FEATURE_DIAGRAM__ANNOTATABLE_ELEMENT); |
155 | } |
156 | return annotatableElement; |
157 | } |
158 | |
159 | /** |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | @Override |
165 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
166 | switch (featureID) { |
167 | case featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE: |
168 | return basicSetRootFeature(null, msgs); |
169 | case featuremodelPackage.FEATURE_DIAGRAM__CONSTRAINTS: |
170 | return ((InternalEList<?>)getConstraints()).basicRemove(otherEnd, msgs); |
171 | } |
172 | return super.eInverseRemove(otherEnd, featureID, msgs); |
173 | } |
174 | |
175 | /** |
176 | * <!-- begin-user-doc --> |
177 | * <!-- end-user-doc --> |
178 | * @generated |
179 | */ |
180 | @Override |
181 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
182 | switch (featureID) { |
183 | case featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE: |
184 | return getRootFeature(); |
185 | case featuremodelPackage.FEATURE_DIAGRAM__CONSTRAINTS: |
186 | return getConstraints(); |
187 | case featuremodelPackage.FEATURE_DIAGRAM__ANNOTATABLE_ELEMENT: |
188 | return getAnnotatableElement(); |
189 | } |
190 | return super.eGet(featureID, resolve, coreType); |
191 | } |
192 | |
193 | /** |
194 | * <!-- begin-user-doc --> |
195 | * <!-- end-user-doc --> |
196 | * @generated |
197 | */ |
198 | @SuppressWarnings("unchecked") |
199 | @Override |
200 | public void eSet(int featureID, Object newValue) { |
201 | switch (featureID) { |
202 | case featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE: |
203 | setRootFeature((Feature)newValue); |
204 | return; |
205 | case featuremodelPackage.FEATURE_DIAGRAM__CONSTRAINTS: |
206 | getConstraints().clear(); |
207 | getConstraints().addAll((Collection<? extends Constraint>)newValue); |
208 | return; |
209 | case featuremodelPackage.FEATURE_DIAGRAM__ANNOTATABLE_ELEMENT: |
210 | getAnnotatableElement().clear(); |
211 | getAnnotatableElement().addAll((Collection<? extends EObject>)newValue); |
212 | return; |
213 | } |
214 | super.eSet(featureID, newValue); |
215 | } |
216 | |
217 | /** |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | @Override |
223 | public void eUnset(int featureID) { |
224 | switch (featureID) { |
225 | case featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE: |
226 | setRootFeature((Feature)null); |
227 | return; |
228 | case featuremodelPackage.FEATURE_DIAGRAM__CONSTRAINTS: |
229 | getConstraints().clear(); |
230 | return; |
231 | case featuremodelPackage.FEATURE_DIAGRAM__ANNOTATABLE_ELEMENT: |
232 | getAnnotatableElement().clear(); |
233 | return; |
234 | } |
235 | super.eUnset(featureID); |
236 | } |
237 | |
238 | /** |
239 | * <!-- begin-user-doc --> |
240 | * <!-- end-user-doc --> |
241 | * @generated |
242 | */ |
243 | @Override |
244 | public boolean eIsSet(int featureID) { |
245 | switch (featureID) { |
246 | case featuremodelPackage.FEATURE_DIAGRAM__ROOT_FEATURE: |
247 | return rootFeature != null; |
248 | case featuremodelPackage.FEATURE_DIAGRAM__CONSTRAINTS: |
249 | return constraints != null && !constraints.isEmpty(); |
250 | case featuremodelPackage.FEATURE_DIAGRAM__ANNOTATABLE_ELEMENT: |
251 | return annotatableElement != null && !annotatableElement.isEmpty(); |
252 | } |
253 | return super.eIsSet(featureID); |
254 | } |
255 | |
256 | } //FeatureDiagramImpl |