1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTBase.impl; |
8 | |
9 | import EMOF.impl.ElementImpl; |
10 | |
11 | import EssentialOCL.OclExpression; |
12 | |
13 | import QVTBase.Pattern; |
14 | import QVTBase.Predicate; |
15 | import QVTBase.QVTBasePackage; |
16 | |
17 | import org.eclipse.emf.common.notify.Notification; |
18 | import org.eclipse.emf.common.notify.NotificationChain; |
19 | |
20 | import org.eclipse.emf.ecore.EClass; |
21 | import org.eclipse.emf.ecore.InternalEObject; |
22 | |
23 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
24 | |
25 | import org.eclipse.emf.ecore.util.EcoreUtil; |
26 | |
27 | /** |
28 | * <!-- begin-user-doc --> |
29 | * An implementation of the model object '<em><b>Predicate</b></em>'. |
30 | * <!-- end-user-doc --> |
31 | * <p> |
32 | * The following features are implemented: |
33 | * <ul> |
34 | * <li>{@link QVTBase.impl.PredicateImpl#getConditionExpression <em>Condition Expression</em>}</li> |
35 | * <li>{@link QVTBase.impl.PredicateImpl#getPattern <em>Pattern</em>}</li> |
36 | * </ul> |
37 | * </p> |
38 | * |
39 | * @generated |
40 | */ |
41 | public class PredicateImpl extends ElementImpl implements Predicate { |
42 | /** |
43 | * The cached value of the '{@link #getConditionExpression() <em>Condition Expression</em>}' containment reference. |
44 | * <!-- begin-user-doc --> |
45 | * <!-- end-user-doc --> |
46 | * @see #getConditionExpression() |
47 | * @generated |
48 | * @ordered |
49 | */ |
50 | protected OclExpression conditionExpression; |
51 | |
52 | /** |
53 | * <!-- begin-user-doc --> |
54 | * <!-- end-user-doc --> |
55 | * @generated |
56 | */ |
57 | protected PredicateImpl() { |
58 | super(); |
59 | } |
60 | |
61 | /** |
62 | * <!-- begin-user-doc --> |
63 | * <!-- end-user-doc --> |
64 | * @generated |
65 | */ |
66 | @Override |
67 | protected EClass eStaticClass() { |
68 | return QVTBasePackage.Literals.PREDICATE; |
69 | } |
70 | |
71 | /** |
72 | * <!-- begin-user-doc --> |
73 | * <!-- end-user-doc --> |
74 | * @generated |
75 | */ |
76 | public OclExpression getConditionExpression() { |
77 | return conditionExpression; |
78 | } |
79 | |
80 | /** |
81 | * <!-- begin-user-doc --> |
82 | * <!-- end-user-doc --> |
83 | * @generated |
84 | */ |
85 | public NotificationChain basicSetConditionExpression(OclExpression newConditionExpression, NotificationChain msgs) { |
86 | OclExpression oldConditionExpression = conditionExpression; |
87 | conditionExpression = newConditionExpression; |
88 | if (eNotificationRequired()) { |
89 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTBasePackage.PREDICATE__CONDITION_EXPRESSION, oldConditionExpression, newConditionExpression); |
90 | if (msgs == null) msgs = notification; else msgs.add(notification); |
91 | } |
92 | return msgs; |
93 | } |
94 | |
95 | /** |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @generated |
99 | */ |
100 | public void setConditionExpression(OclExpression newConditionExpression) { |
101 | if (newConditionExpression != conditionExpression) { |
102 | NotificationChain msgs = null; |
103 | if (conditionExpression != null) |
104 | msgs = ((InternalEObject)conditionExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTBasePackage.PREDICATE__CONDITION_EXPRESSION, null, msgs); |
105 | if (newConditionExpression != null) |
106 | msgs = ((InternalEObject)newConditionExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTBasePackage.PREDICATE__CONDITION_EXPRESSION, null, msgs); |
107 | msgs = basicSetConditionExpression(newConditionExpression, msgs); |
108 | if (msgs != null) msgs.dispatch(); |
109 | } |
110 | else if (eNotificationRequired()) |
111 | eNotify(new ENotificationImpl(this, Notification.SET, QVTBasePackage.PREDICATE__CONDITION_EXPRESSION, newConditionExpression, newConditionExpression)); |
112 | } |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | public Pattern getPattern() { |
120 | if (eContainerFeatureID() != QVTBasePackage.PREDICATE__PATTERN) return null; |
121 | return (Pattern)eContainer(); |
122 | } |
123 | |
124 | /** |
125 | * <!-- begin-user-doc --> |
126 | * <!-- end-user-doc --> |
127 | * @generated |
128 | */ |
129 | public NotificationChain basicSetPattern(Pattern newPattern, NotificationChain msgs) { |
130 | msgs = eBasicSetContainer((InternalEObject)newPattern, QVTBasePackage.PREDICATE__PATTERN, msgs); |
131 | return msgs; |
132 | } |
133 | |
134 | /** |
135 | * <!-- begin-user-doc --> |
136 | * <!-- end-user-doc --> |
137 | * @generated |
138 | */ |
139 | public void setPattern(Pattern newPattern) { |
140 | if (newPattern != eInternalContainer() || (eContainerFeatureID() != QVTBasePackage.PREDICATE__PATTERN && newPattern != null)) { |
141 | if (EcoreUtil.isAncestor(this, newPattern)) |
142 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
143 | NotificationChain msgs = null; |
144 | if (eInternalContainer() != null) |
145 | msgs = eBasicRemoveFromContainer(msgs); |
146 | if (newPattern != null) |
147 | msgs = ((InternalEObject)newPattern).eInverseAdd(this, QVTBasePackage.PATTERN__PREDICATE, Pattern.class, msgs); |
148 | msgs = basicSetPattern(newPattern, msgs); |
149 | if (msgs != null) msgs.dispatch(); |
150 | } |
151 | else if (eNotificationRequired()) |
152 | eNotify(new ENotificationImpl(this, Notification.SET, QVTBasePackage.PREDICATE__PATTERN, newPattern, newPattern)); |
153 | } |
154 | |
155 | /** |
156 | * <!-- begin-user-doc --> |
157 | * <!-- end-user-doc --> |
158 | * @generated |
159 | */ |
160 | @Override |
161 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
162 | switch (featureID) { |
163 | case QVTBasePackage.PREDICATE__PATTERN: |
164 | if (eInternalContainer() != null) |
165 | msgs = eBasicRemoveFromContainer(msgs); |
166 | return basicSetPattern((Pattern)otherEnd, msgs); |
167 | } |
168 | return super.eInverseAdd(otherEnd, featureID, msgs); |
169 | } |
170 | |
171 | /** |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | @Override |
177 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
178 | switch (featureID) { |
179 | case QVTBasePackage.PREDICATE__CONDITION_EXPRESSION: |
180 | return basicSetConditionExpression(null, msgs); |
181 | case QVTBasePackage.PREDICATE__PATTERN: |
182 | return basicSetPattern(null, msgs); |
183 | } |
184 | return super.eInverseRemove(otherEnd, featureID, msgs); |
185 | } |
186 | |
187 | /** |
188 | * <!-- begin-user-doc --> |
189 | * <!-- end-user-doc --> |
190 | * @generated |
191 | */ |
192 | @Override |
193 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
194 | switch (eContainerFeatureID()) { |
195 | case QVTBasePackage.PREDICATE__PATTERN: |
196 | return eInternalContainer().eInverseRemove(this, QVTBasePackage.PATTERN__PREDICATE, Pattern.class, msgs); |
197 | } |
198 | return super.eBasicRemoveFromContainerFeature(msgs); |
199 | } |
200 | |
201 | /** |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @generated |
205 | */ |
206 | @Override |
207 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
208 | switch (featureID) { |
209 | case QVTBasePackage.PREDICATE__CONDITION_EXPRESSION: |
210 | return getConditionExpression(); |
211 | case QVTBasePackage.PREDICATE__PATTERN: |
212 | return getPattern(); |
213 | } |
214 | return super.eGet(featureID, resolve, coreType); |
215 | } |
216 | |
217 | /** |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | @Override |
223 | public void eSet(int featureID, Object newValue) { |
224 | switch (featureID) { |
225 | case QVTBasePackage.PREDICATE__CONDITION_EXPRESSION: |
226 | setConditionExpression((OclExpression)newValue); |
227 | return; |
228 | case QVTBasePackage.PREDICATE__PATTERN: |
229 | setPattern((Pattern)newValue); |
230 | return; |
231 | } |
232 | super.eSet(featureID, newValue); |
233 | } |
234 | |
235 | /** |
236 | * <!-- begin-user-doc --> |
237 | * <!-- end-user-doc --> |
238 | * @generated |
239 | */ |
240 | @Override |
241 | public void eUnset(int featureID) { |
242 | switch (featureID) { |
243 | case QVTBasePackage.PREDICATE__CONDITION_EXPRESSION: |
244 | setConditionExpression((OclExpression)null); |
245 | return; |
246 | case QVTBasePackage.PREDICATE__PATTERN: |
247 | setPattern((Pattern)null); |
248 | return; |
249 | } |
250 | super.eUnset(featureID); |
251 | } |
252 | |
253 | /** |
254 | * <!-- begin-user-doc --> |
255 | * <!-- end-user-doc --> |
256 | * @generated |
257 | */ |
258 | @Override |
259 | public boolean eIsSet(int featureID) { |
260 | switch (featureID) { |
261 | case QVTBasePackage.PREDICATE__CONDITION_EXPRESSION: |
262 | return conditionExpression != null; |
263 | case QVTBasePackage.PREDICATE__PATTERN: |
264 | return getPattern() != null; |
265 | } |
266 | return super.eIsSet(featureID); |
267 | } |
268 | |
269 | } //PredicateImpl |