1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featureconfig.impl; |
8 | |
9 | import de.uka.ipd.sdq.featureconfig.ExternalObjectAttributeValue; |
10 | import de.uka.ipd.sdq.featureconfig.featureconfigPackage; |
11 | |
12 | import de.uka.ipd.sdq.featureconfig.util.featureconfigValidator; |
13 | |
14 | import java.util.Map; |
15 | |
16 | import org.eclipse.emf.common.notify.Notification; |
17 | |
18 | import org.eclipse.emf.common.util.BasicDiagnostic; |
19 | import org.eclipse.emf.common.util.Diagnostic; |
20 | import org.eclipse.emf.common.util.DiagnosticChain; |
21 | |
22 | import org.eclipse.emf.ecore.EClass; |
23 | import org.eclipse.emf.ecore.EObject; |
24 | import org.eclipse.emf.ecore.InternalEObject; |
25 | |
26 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
27 | |
28 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
29 | |
30 | import org.eclipse.emf.ecore.util.EObjectValidator; |
31 | |
32 | import org.eclipse.ocl.ParserException; |
33 | |
34 | import org.eclipse.ocl.ecore.Constraint; |
35 | import org.eclipse.ocl.ecore.OCL; |
36 | |
37 | /** |
38 | * <!-- begin-user-doc --> |
39 | * An implementation of the model object '<em><b>External Object Attribute Value</b></em>'. |
40 | * <!-- end-user-doc --> |
41 | * <p> |
42 | * The following features are implemented: |
43 | * <ul> |
44 | * <li>{@link de.uka.ipd.sdq.featureconfig.impl.ExternalObjectAttributeValueImpl#getReferencedObject <em>Referenced Object</em>}</li> |
45 | * </ul> |
46 | * </p> |
47 | * |
48 | * @generated |
49 | */ |
50 | public class ExternalObjectAttributeValueImpl extends AttributeValueImpl implements ExternalObjectAttributeValue { |
51 | /** |
52 | * The cached value of the '{@link #getReferencedObject() <em>Referenced Object</em>}' reference. |
53 | * <!-- begin-user-doc --> |
54 | * <!-- end-user-doc --> |
55 | * @see #getReferencedObject() |
56 | * @generated |
57 | * @ordered |
58 | */ |
59 | protected EObject referencedObject; |
60 | |
61 | /** |
62 | * <!-- begin-user-doc --> |
63 | * <!-- end-user-doc --> |
64 | * @generated |
65 | */ |
66 | protected ExternalObjectAttributeValueImpl() { |
67 | super(); |
68 | } |
69 | |
70 | /** |
71 | * <!-- begin-user-doc --> |
72 | * <!-- end-user-doc --> |
73 | * @generated |
74 | */ |
75 | @Override |
76 | protected EClass eStaticClass() { |
77 | return featureconfigPackage.Literals.EXTERNAL_OBJECT_ATTRIBUTE_VALUE; |
78 | } |
79 | |
80 | /** |
81 | * <!-- begin-user-doc --> |
82 | * <!-- end-user-doc --> |
83 | * @generated |
84 | */ |
85 | public EObject getReferencedObject() { |
86 | if (referencedObject != null && referencedObject.eIsProxy()) { |
87 | InternalEObject oldReferencedObject = (InternalEObject)referencedObject; |
88 | referencedObject = eResolveProxy(oldReferencedObject); |
89 | if (referencedObject != oldReferencedObject) { |
90 | if (eNotificationRequired()) |
91 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, featureconfigPackage.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__REFERENCED_OBJECT, oldReferencedObject, referencedObject)); |
92 | } |
93 | } |
94 | return referencedObject; |
95 | } |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | public EObject basicGetReferencedObject() { |
103 | return referencedObject; |
104 | } |
105 | |
106 | /** |
107 | * <!-- begin-user-doc --> |
108 | * <!-- end-user-doc --> |
109 | * @generated |
110 | */ |
111 | public void setReferencedObject(EObject newReferencedObject) { |
112 | EObject oldReferencedObject = referencedObject; |
113 | referencedObject = newReferencedObject; |
114 | if (eNotificationRequired()) |
115 | eNotify(new ENotificationImpl(this, Notification.SET, featureconfigPackage.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__REFERENCED_OBJECT, oldReferencedObject, referencedObject)); |
116 | } |
117 | |
118 | /** |
119 | * The cached OCL expression body for the '{@link #AttributeValueIsDefinedInFeatureAndEqualsTypeExternalObject(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Attribute Value Is Defined In Feature And Equals Type External Object</em>}' operation. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @see #AttributeValueIsDefinedInFeatureAndEqualsTypeExternalObject(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
123 | * @generated |
124 | * @ordered |
125 | */ |
126 | protected static final String ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.confignode.origin.attributes->one(a | a.name = self.name)"+ |
127 | " and"+ |
128 | " self.confignode.origin.attributes->any(a | a.name = self.name).oclIsTypeOf(featuremodel::ExternalObjectAttribute)"; |
129 | |
130 | /** |
131 | * The cached OCL invariant for the '{@link #AttributeValueIsDefinedInFeatureAndEqualsTypeExternalObject(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Attribute Value Is Defined In Feature And Equals Type External Object</em>}' invariant operation. |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @see #AttributeValueIsDefinedInFeatureAndEqualsTypeExternalObject(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
135 | * @generated |
136 | * @ordered |
137 | */ |
138 | protected static Constraint ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
139 | |
140 | /** |
141 | * <!-- begin-user-doc --> |
142 | * <!-- end-user-doc --> |
143 | * @generated |
144 | */ |
145 | public boolean AttributeValueIsDefinedInFeatureAndEqualsTypeExternalObject(DiagnosticChain diagnostics, Map<Object, Object> context) { |
146 | if (ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
147 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
148 | helper.setContext(featureconfigPackage.Literals.EXTERNAL_OBJECT_ATTRIBUTE_VALUE); |
149 | try { |
150 | ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
151 | } |
152 | catch (ParserException pe) { |
153 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
154 | } |
155 | } |
156 | if (!EOCL_ENV.createQuery(ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
157 | if (diagnostics != null) { |
158 | diagnostics.add |
159 | (new BasicDiagnostic |
160 | (Diagnostic.ERROR, |
161 | featureconfigValidator.DIAGNOSTIC_SOURCE, |
162 | featureconfigValidator.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__ATTRIBUTE_VALUE_IS_DEFINED_IN_FEATURE_AND_EQUALS_TYPE_EXTERNAL_OBJECT, |
163 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "AttributeValueIsDefinedInFeatureAndEqualsTypeExternalObject", EObjectValidator.getObjectLabel(this, context) }), |
164 | new Object [] { this })); |
165 | } |
166 | return false; |
167 | } |
168 | return true; |
169 | } |
170 | |
171 | /** |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | @Override |
177 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
178 | switch (featureID) { |
179 | case featureconfigPackage.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__REFERENCED_OBJECT: |
180 | if (resolve) return getReferencedObject(); |
181 | return basicGetReferencedObject(); |
182 | } |
183 | return super.eGet(featureID, resolve, coreType); |
184 | } |
185 | |
186 | /** |
187 | * <!-- begin-user-doc --> |
188 | * <!-- end-user-doc --> |
189 | * @generated |
190 | */ |
191 | @Override |
192 | public void eSet(int featureID, Object newValue) { |
193 | switch (featureID) { |
194 | case featureconfigPackage.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__REFERENCED_OBJECT: |
195 | setReferencedObject((EObject)newValue); |
196 | return; |
197 | } |
198 | super.eSet(featureID, newValue); |
199 | } |
200 | |
201 | /** |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @generated |
205 | */ |
206 | @Override |
207 | public void eUnset(int featureID) { |
208 | switch (featureID) { |
209 | case featureconfigPackage.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__REFERENCED_OBJECT: |
210 | setReferencedObject((EObject)null); |
211 | return; |
212 | } |
213 | super.eUnset(featureID); |
214 | } |
215 | |
216 | /** |
217 | * <!-- begin-user-doc --> |
218 | * <!-- end-user-doc --> |
219 | * @generated |
220 | */ |
221 | @Override |
222 | public boolean eIsSet(int featureID) { |
223 | switch (featureID) { |
224 | case featureconfigPackage.EXTERNAL_OBJECT_ATTRIBUTE_VALUE__REFERENCED_OBJECT: |
225 | return referencedObject != null; |
226 | } |
227 | return super.eIsSet(featureID); |
228 | } |
229 | |
230 | /** |
231 | * The cached environment for evaluating OCL expressions. |
232 | * <!-- begin-user-doc --> |
233 | * <!-- end-user-doc --> |
234 | * @generated |
235 | * @ordered |
236 | */ |
237 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
238 | |
239 | } //ExternalObjectAttributeValueImpl |