1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTRelation.impl; |
8 | |
9 | import EssentialOCL.Variable; |
10 | |
11 | import QVTBase.impl.DomainImpl; |
12 | |
13 | import QVTRelation.DomainPattern; |
14 | import QVTRelation.QVTRelationPackage; |
15 | import QVTRelation.RelationDomain; |
16 | import QVTRelation.RelationDomainAssignment; |
17 | |
18 | import java.util.Collection; |
19 | |
20 | import org.eclipse.emf.common.notify.Notification; |
21 | import org.eclipse.emf.common.notify.NotificationChain; |
22 | |
23 | import org.eclipse.emf.common.util.EList; |
24 | |
25 | import org.eclipse.emf.ecore.EClass; |
26 | import org.eclipse.emf.ecore.InternalEObject; |
27 | |
28 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
29 | |
30 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
31 | import org.eclipse.emf.ecore.util.InternalEList; |
32 | |
33 | /** |
34 | * <!-- begin-user-doc --> |
35 | * An implementation of the model object '<em><b>Relation Domain</b></em>'. |
36 | * <!-- end-user-doc --> |
37 | * <p> |
38 | * The following features are implemented: |
39 | * <ul> |
40 | * <li>{@link QVTRelation.impl.RelationDomainImpl#getDefaultAssignment <em>Default Assignment</em>}</li> |
41 | * <li>{@link QVTRelation.impl.RelationDomainImpl#getPattern <em>Pattern</em>}</li> |
42 | * <li>{@link QVTRelation.impl.RelationDomainImpl#getRootVariable <em>Root Variable</em>}</li> |
43 | * </ul> |
44 | * </p> |
45 | * |
46 | * @generated |
47 | */ |
48 | public class RelationDomainImpl extends DomainImpl implements RelationDomain { |
49 | /** |
50 | * The cached value of the '{@link #getDefaultAssignment() <em>Default Assignment</em>}' containment reference list. |
51 | * <!-- begin-user-doc --> |
52 | * <!-- end-user-doc --> |
53 | * @see #getDefaultAssignment() |
54 | * @generated |
55 | * @ordered |
56 | */ |
57 | protected EList<RelationDomainAssignment> defaultAssignment; |
58 | |
59 | /** |
60 | * The cached value of the '{@link #getPattern() <em>Pattern</em>}' containment reference. |
61 | * <!-- begin-user-doc --> |
62 | * <!-- end-user-doc --> |
63 | * @see #getPattern() |
64 | * @generated |
65 | * @ordered |
66 | */ |
67 | protected DomainPattern pattern; |
68 | |
69 | /** |
70 | * The cached value of the '{@link #getRootVariable() <em>Root Variable</em>}' reference. |
71 | * <!-- begin-user-doc --> |
72 | * <!-- end-user-doc --> |
73 | * @see #getRootVariable() |
74 | * @generated |
75 | * @ordered |
76 | */ |
77 | protected Variable rootVariable; |
78 | |
79 | /** |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected RelationDomainImpl() { |
85 | super(); |
86 | } |
87 | |
88 | /** |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @generated |
92 | */ |
93 | @Override |
94 | protected EClass eStaticClass() { |
95 | return QVTRelationPackage.Literals.RELATION_DOMAIN; |
96 | } |
97 | |
98 | /** |
99 | * <!-- begin-user-doc --> |
100 | * <!-- end-user-doc --> |
101 | * @generated |
102 | */ |
103 | public EList<RelationDomainAssignment> getDefaultAssignment() { |
104 | if (defaultAssignment == null) { |
105 | defaultAssignment = new EObjectContainmentEList<RelationDomainAssignment>(RelationDomainAssignment.class, this, QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT); |
106 | } |
107 | return defaultAssignment; |
108 | } |
109 | |
110 | /** |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | public DomainPattern getPattern() { |
116 | return pattern; |
117 | } |
118 | |
119 | /** |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | public NotificationChain basicSetPattern(DomainPattern newPattern, NotificationChain msgs) { |
125 | DomainPattern oldPattern = pattern; |
126 | pattern = newPattern; |
127 | if (eNotificationRequired()) { |
128 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION_DOMAIN__PATTERN, oldPattern, newPattern); |
129 | if (msgs == null) msgs = notification; else msgs.add(notification); |
130 | } |
131 | return msgs; |
132 | } |
133 | |
134 | /** |
135 | * <!-- begin-user-doc --> |
136 | * <!-- end-user-doc --> |
137 | * @generated |
138 | */ |
139 | public void setPattern(DomainPattern newPattern) { |
140 | if (newPattern != pattern) { |
141 | NotificationChain msgs = null; |
142 | if (pattern != null) |
143 | msgs = ((InternalEObject)pattern).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTRelationPackage.RELATION_DOMAIN__PATTERN, null, msgs); |
144 | if (newPattern != null) |
145 | msgs = ((InternalEObject)newPattern).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTRelationPackage.RELATION_DOMAIN__PATTERN, null, msgs); |
146 | msgs = basicSetPattern(newPattern, msgs); |
147 | if (msgs != null) msgs.dispatch(); |
148 | } |
149 | else if (eNotificationRequired()) |
150 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION_DOMAIN__PATTERN, newPattern, newPattern)); |
151 | } |
152 | |
153 | /** |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | public Variable getRootVariable() { |
159 | if (rootVariable != null && rootVariable.eIsProxy()) { |
160 | InternalEObject oldRootVariable = (InternalEObject)rootVariable; |
161 | rootVariable = (Variable)eResolveProxy(oldRootVariable); |
162 | if (rootVariable != oldRootVariable) { |
163 | if (eNotificationRequired()) |
164 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QVTRelationPackage.RELATION_DOMAIN__ROOT_VARIABLE, oldRootVariable, rootVariable)); |
165 | } |
166 | } |
167 | return rootVariable; |
168 | } |
169 | |
170 | /** |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @generated |
174 | */ |
175 | public Variable basicGetRootVariable() { |
176 | return rootVariable; |
177 | } |
178 | |
179 | /** |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | public void setRootVariable(Variable newRootVariable) { |
185 | Variable oldRootVariable = rootVariable; |
186 | rootVariable = newRootVariable; |
187 | if (eNotificationRequired()) |
188 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION_DOMAIN__ROOT_VARIABLE, oldRootVariable, rootVariable)); |
189 | } |
190 | |
191 | /** |
192 | * <!-- begin-user-doc --> |
193 | * <!-- end-user-doc --> |
194 | * @generated |
195 | */ |
196 | @Override |
197 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
198 | switch (featureID) { |
199 | case QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT: |
200 | return ((InternalEList<?>)getDefaultAssignment()).basicRemove(otherEnd, msgs); |
201 | case QVTRelationPackage.RELATION_DOMAIN__PATTERN: |
202 | return basicSetPattern(null, msgs); |
203 | } |
204 | return super.eInverseRemove(otherEnd, featureID, msgs); |
205 | } |
206 | |
207 | /** |
208 | * <!-- begin-user-doc --> |
209 | * <!-- end-user-doc --> |
210 | * @generated |
211 | */ |
212 | @Override |
213 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
214 | switch (featureID) { |
215 | case QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT: |
216 | return getDefaultAssignment(); |
217 | case QVTRelationPackage.RELATION_DOMAIN__PATTERN: |
218 | return getPattern(); |
219 | case QVTRelationPackage.RELATION_DOMAIN__ROOT_VARIABLE: |
220 | if (resolve) return getRootVariable(); |
221 | return basicGetRootVariable(); |
222 | } |
223 | return super.eGet(featureID, resolve, coreType); |
224 | } |
225 | |
226 | /** |
227 | * <!-- begin-user-doc --> |
228 | * <!-- end-user-doc --> |
229 | * @generated |
230 | */ |
231 | @SuppressWarnings("unchecked") |
232 | @Override |
233 | public void eSet(int featureID, Object newValue) { |
234 | switch (featureID) { |
235 | case QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT: |
236 | getDefaultAssignment().clear(); |
237 | getDefaultAssignment().addAll((Collection<? extends RelationDomainAssignment>)newValue); |
238 | return; |
239 | case QVTRelationPackage.RELATION_DOMAIN__PATTERN: |
240 | setPattern((DomainPattern)newValue); |
241 | return; |
242 | case QVTRelationPackage.RELATION_DOMAIN__ROOT_VARIABLE: |
243 | setRootVariable((Variable)newValue); |
244 | return; |
245 | } |
246 | super.eSet(featureID, newValue); |
247 | } |
248 | |
249 | /** |
250 | * <!-- begin-user-doc --> |
251 | * <!-- end-user-doc --> |
252 | * @generated |
253 | */ |
254 | @Override |
255 | public void eUnset(int featureID) { |
256 | switch (featureID) { |
257 | case QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT: |
258 | getDefaultAssignment().clear(); |
259 | return; |
260 | case QVTRelationPackage.RELATION_DOMAIN__PATTERN: |
261 | setPattern((DomainPattern)null); |
262 | return; |
263 | case QVTRelationPackage.RELATION_DOMAIN__ROOT_VARIABLE: |
264 | setRootVariable((Variable)null); |
265 | return; |
266 | } |
267 | super.eUnset(featureID); |
268 | } |
269 | |
270 | /** |
271 | * <!-- begin-user-doc --> |
272 | * <!-- end-user-doc --> |
273 | * @generated |
274 | */ |
275 | @Override |
276 | public boolean eIsSet(int featureID) { |
277 | switch (featureID) { |
278 | case QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT: |
279 | return defaultAssignment != null && !defaultAssignment.isEmpty(); |
280 | case QVTRelationPackage.RELATION_DOMAIN__PATTERN: |
281 | return pattern != null; |
282 | case QVTRelationPackage.RELATION_DOMAIN__ROOT_VARIABLE: |
283 | return rootVariable != null; |
284 | } |
285 | return super.eIsSet(featureID); |
286 | } |
287 | |
288 | } //RelationDomainImpl |