| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EssentialOCL.impl; |
| 8 | |
| 9 | import EMOF.impl.TypedElementImpl; |
| 10 | |
| 11 | import EssentialOCL.EssentialOCLPackage; |
| 12 | import EssentialOCL.ExpressionInOcl; |
| 13 | import EssentialOCL.OclExpression; |
| 14 | import EssentialOCL.Variable; |
| 15 | |
| 16 | import java.util.Collection; |
| 17 | |
| 18 | import org.eclipse.emf.common.notify.Notification; |
| 19 | import org.eclipse.emf.common.notify.NotificationChain; |
| 20 | |
| 21 | import org.eclipse.emf.common.util.EList; |
| 22 | |
| 23 | import org.eclipse.emf.ecore.EClass; |
| 24 | import org.eclipse.emf.ecore.InternalEObject; |
| 25 | |
| 26 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 27 | |
| 28 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 29 | import org.eclipse.emf.ecore.util.InternalEList; |
| 30 | |
| 31 | /** |
| 32 | * <!-- begin-user-doc --> |
| 33 | * An implementation of the model object '<em><b>Expression In Ocl</b></em>'. |
| 34 | * <!-- end-user-doc --> |
| 35 | * <p> |
| 36 | * The following features are implemented: |
| 37 | * <ul> |
| 38 | * <li>{@link EssentialOCL.impl.ExpressionInOclImpl#getBodyExpression <em>Body Expression</em>}</li> |
| 39 | * <li>{@link EssentialOCL.impl.ExpressionInOclImpl#getContextVariable <em>Context Variable</em>}</li> |
| 40 | * <li>{@link EssentialOCL.impl.ExpressionInOclImpl#getParameterVariable <em>Parameter Variable</em>}</li> |
| 41 | * <li>{@link EssentialOCL.impl.ExpressionInOclImpl#getResultVariable <em>Result Variable</em>}</li> |
| 42 | * </ul> |
| 43 | * </p> |
| 44 | * |
| 45 | * @generated |
| 46 | */ |
| 47 | public class ExpressionInOclImpl extends TypedElementImpl implements ExpressionInOcl { |
| 48 | /** |
| 49 | * The cached value of the '{@link #getBodyExpression() <em>Body Expression</em>}' containment reference. |
| 50 | * <!-- begin-user-doc --> |
| 51 | * <!-- end-user-doc --> |
| 52 | * @see #getBodyExpression() |
| 53 | * @generated |
| 54 | * @ordered |
| 55 | */ |
| 56 | protected OclExpression bodyExpression; |
| 57 | |
| 58 | /** |
| 59 | * The cached value of the '{@link #getContextVariable() <em>Context Variable</em>}' containment reference. |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @see #getContextVariable() |
| 63 | * @generated |
| 64 | * @ordered |
| 65 | */ |
| 66 | protected Variable contextVariable; |
| 67 | |
| 68 | /** |
| 69 | * The cached value of the '{@link #getParameterVariable() <em>Parameter Variable</em>}' containment reference list. |
| 70 | * <!-- begin-user-doc --> |
| 71 | * <!-- end-user-doc --> |
| 72 | * @see #getParameterVariable() |
| 73 | * @generated |
| 74 | * @ordered |
| 75 | */ |
| 76 | protected EList<Variable> parameterVariable; |
| 77 | |
| 78 | /** |
| 79 | * The cached value of the '{@link #getResultVariable() <em>Result Variable</em>}' containment reference. |
| 80 | * <!-- begin-user-doc --> |
| 81 | * <!-- end-user-doc --> |
| 82 | * @see #getResultVariable() |
| 83 | * @generated |
| 84 | * @ordered |
| 85 | */ |
| 86 | protected Variable resultVariable; |
| 87 | |
| 88 | /** |
| 89 | * <!-- begin-user-doc --> |
| 90 | * <!-- end-user-doc --> |
| 91 | * @generated |
| 92 | */ |
| 93 | protected ExpressionInOclImpl() { |
| 94 | super(); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * <!-- begin-user-doc --> |
| 99 | * <!-- end-user-doc --> |
| 100 | * @generated |
| 101 | */ |
| 102 | @Override |
| 103 | protected EClass eStaticClass() { |
| 104 | return EssentialOCLPackage.Literals.EXPRESSION_IN_OCL; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * <!-- begin-user-doc --> |
| 109 | * <!-- end-user-doc --> |
| 110 | * @generated |
| 111 | */ |
| 112 | public OclExpression getBodyExpression() { |
| 113 | return bodyExpression; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | public NotificationChain basicSetBodyExpression(OclExpression newBodyExpression, NotificationChain msgs) { |
| 122 | OclExpression oldBodyExpression = bodyExpression; |
| 123 | bodyExpression = newBodyExpression; |
| 124 | if (eNotificationRequired()) { |
| 125 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION, oldBodyExpression, newBodyExpression); |
| 126 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 127 | } |
| 128 | return msgs; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | public void setBodyExpression(OclExpression newBodyExpression) { |
| 137 | if (newBodyExpression != bodyExpression) { |
| 138 | NotificationChain msgs = null; |
| 139 | if (bodyExpression != null) |
| 140 | msgs = ((InternalEObject)bodyExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION, null, msgs); |
| 141 | if (newBodyExpression != null) |
| 142 | msgs = ((InternalEObject)newBodyExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION, null, msgs); |
| 143 | msgs = basicSetBodyExpression(newBodyExpression, msgs); |
| 144 | if (msgs != null) msgs.dispatch(); |
| 145 | } |
| 146 | else if (eNotificationRequired()) |
| 147 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION, newBodyExpression, newBodyExpression)); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * <!-- begin-user-doc --> |
| 152 | * <!-- end-user-doc --> |
| 153 | * @generated |
| 154 | */ |
| 155 | public Variable getContextVariable() { |
| 156 | return contextVariable; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * <!-- begin-user-doc --> |
| 161 | * <!-- end-user-doc --> |
| 162 | * @generated |
| 163 | */ |
| 164 | public NotificationChain basicSetContextVariable(Variable newContextVariable, NotificationChain msgs) { |
| 165 | Variable oldContextVariable = contextVariable; |
| 166 | contextVariable = newContextVariable; |
| 167 | if (eNotificationRequired()) { |
| 168 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE, oldContextVariable, newContextVariable); |
| 169 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 170 | } |
| 171 | return msgs; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * <!-- begin-user-doc --> |
| 176 | * <!-- end-user-doc --> |
| 177 | * @generated |
| 178 | */ |
| 179 | public void setContextVariable(Variable newContextVariable) { |
| 180 | if (newContextVariable != contextVariable) { |
| 181 | NotificationChain msgs = null; |
| 182 | if (contextVariable != null) |
| 183 | msgs = ((InternalEObject)contextVariable).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE, null, msgs); |
| 184 | if (newContextVariable != null) |
| 185 | msgs = ((InternalEObject)newContextVariable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE, null, msgs); |
| 186 | msgs = basicSetContextVariable(newContextVariable, msgs); |
| 187 | if (msgs != null) msgs.dispatch(); |
| 188 | } |
| 189 | else if (eNotificationRequired()) |
| 190 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE, newContextVariable, newContextVariable)); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * <!-- begin-user-doc --> |
| 195 | * <!-- end-user-doc --> |
| 196 | * @generated |
| 197 | */ |
| 198 | public EList<Variable> getParameterVariable() { |
| 199 | if (parameterVariable == null) { |
| 200 | parameterVariable = new EObjectContainmentEList<Variable>(Variable.class, this, EssentialOCLPackage.EXPRESSION_IN_OCL__PARAMETER_VARIABLE); |
| 201 | } |
| 202 | return parameterVariable; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * <!-- begin-user-doc --> |
| 207 | * <!-- end-user-doc --> |
| 208 | * @generated |
| 209 | */ |
| 210 | public Variable getResultVariable() { |
| 211 | return resultVariable; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * <!-- begin-user-doc --> |
| 216 | * <!-- end-user-doc --> |
| 217 | * @generated |
| 218 | */ |
| 219 | public NotificationChain basicSetResultVariable(Variable newResultVariable, NotificationChain msgs) { |
| 220 | Variable oldResultVariable = resultVariable; |
| 221 | resultVariable = newResultVariable; |
| 222 | if (eNotificationRequired()) { |
| 223 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE, oldResultVariable, newResultVariable); |
| 224 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 225 | } |
| 226 | return msgs; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * <!-- begin-user-doc --> |
| 231 | * <!-- end-user-doc --> |
| 232 | * @generated |
| 233 | */ |
| 234 | public void setResultVariable(Variable newResultVariable) { |
| 235 | if (newResultVariable != resultVariable) { |
| 236 | NotificationChain msgs = null; |
| 237 | if (resultVariable != null) |
| 238 | msgs = ((InternalEObject)resultVariable).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE, null, msgs); |
| 239 | if (newResultVariable != null) |
| 240 | msgs = ((InternalEObject)newResultVariable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE, null, msgs); |
| 241 | msgs = basicSetResultVariable(newResultVariable, msgs); |
| 242 | if (msgs != null) msgs.dispatch(); |
| 243 | } |
| 244 | else if (eNotificationRequired()) |
| 245 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE, newResultVariable, newResultVariable)); |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * <!-- begin-user-doc --> |
| 250 | * <!-- end-user-doc --> |
| 251 | * @generated |
| 252 | */ |
| 253 | @Override |
| 254 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 255 | switch (featureID) { |
| 256 | case EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION: |
| 257 | return basicSetBodyExpression(null, msgs); |
| 258 | case EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE: |
| 259 | return basicSetContextVariable(null, msgs); |
| 260 | case EssentialOCLPackage.EXPRESSION_IN_OCL__PARAMETER_VARIABLE: |
| 261 | return ((InternalEList<?>)getParameterVariable()).basicRemove(otherEnd, msgs); |
| 262 | case EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE: |
| 263 | return basicSetResultVariable(null, msgs); |
| 264 | } |
| 265 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * <!-- begin-user-doc --> |
| 270 | * <!-- end-user-doc --> |
| 271 | * @generated |
| 272 | */ |
| 273 | @Override |
| 274 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 275 | switch (featureID) { |
| 276 | case EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION: |
| 277 | return getBodyExpression(); |
| 278 | case EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE: |
| 279 | return getContextVariable(); |
| 280 | case EssentialOCLPackage.EXPRESSION_IN_OCL__PARAMETER_VARIABLE: |
| 281 | return getParameterVariable(); |
| 282 | case EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE: |
| 283 | return getResultVariable(); |
| 284 | } |
| 285 | return super.eGet(featureID, resolve, coreType); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * <!-- begin-user-doc --> |
| 290 | * <!-- end-user-doc --> |
| 291 | * @generated |
| 292 | */ |
| 293 | @SuppressWarnings("unchecked") |
| 294 | @Override |
| 295 | public void eSet(int featureID, Object newValue) { |
| 296 | switch (featureID) { |
| 297 | case EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION: |
| 298 | setBodyExpression((OclExpression)newValue); |
| 299 | return; |
| 300 | case EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE: |
| 301 | setContextVariable((Variable)newValue); |
| 302 | return; |
| 303 | case EssentialOCLPackage.EXPRESSION_IN_OCL__PARAMETER_VARIABLE: |
| 304 | getParameterVariable().clear(); |
| 305 | getParameterVariable().addAll((Collection<? extends Variable>)newValue); |
| 306 | return; |
| 307 | case EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE: |
| 308 | setResultVariable((Variable)newValue); |
| 309 | return; |
| 310 | } |
| 311 | super.eSet(featureID, newValue); |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * <!-- begin-user-doc --> |
| 316 | * <!-- end-user-doc --> |
| 317 | * @generated |
| 318 | */ |
| 319 | @Override |
| 320 | public void eUnset(int featureID) { |
| 321 | switch (featureID) { |
| 322 | case EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION: |
| 323 | setBodyExpression((OclExpression)null); |
| 324 | return; |
| 325 | case EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE: |
| 326 | setContextVariable((Variable)null); |
| 327 | return; |
| 328 | case EssentialOCLPackage.EXPRESSION_IN_OCL__PARAMETER_VARIABLE: |
| 329 | getParameterVariable().clear(); |
| 330 | return; |
| 331 | case EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE: |
| 332 | setResultVariable((Variable)null); |
| 333 | return; |
| 334 | } |
| 335 | super.eUnset(featureID); |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * <!-- begin-user-doc --> |
| 340 | * <!-- end-user-doc --> |
| 341 | * @generated |
| 342 | */ |
| 343 | @Override |
| 344 | public boolean eIsSet(int featureID) { |
| 345 | switch (featureID) { |
| 346 | case EssentialOCLPackage.EXPRESSION_IN_OCL__BODY_EXPRESSION: |
| 347 | return bodyExpression != null; |
| 348 | case EssentialOCLPackage.EXPRESSION_IN_OCL__CONTEXT_VARIABLE: |
| 349 | return contextVariable != null; |
| 350 | case EssentialOCLPackage.EXPRESSION_IN_OCL__PARAMETER_VARIABLE: |
| 351 | return parameterVariable != null && !parameterVariable.isEmpty(); |
| 352 | case EssentialOCLPackage.EXPRESSION_IN_OCL__RESULT_VARIABLE: |
| 353 | return resultVariable != null; |
| 354 | } |
| 355 | return super.eIsSet(featureID); |
| 356 | } |
| 357 | |
| 358 | } //ExpressionInOclImpl |