| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EssentialOCL.impl; |
| 8 | |
| 9 | import EMOF.Property; |
| 10 | |
| 11 | import EMOF.impl.TypedElementImpl; |
| 12 | |
| 13 | import EssentialOCL.EssentialOCLPackage; |
| 14 | import EssentialOCL.OclExpression; |
| 15 | import EssentialOCL.TupleLiteralExp; |
| 16 | import EssentialOCL.TupleLiteralPart; |
| 17 | |
| 18 | import org.eclipse.emf.common.notify.Notification; |
| 19 | import org.eclipse.emf.common.notify.NotificationChain; |
| 20 | |
| 21 | import org.eclipse.emf.ecore.EClass; |
| 22 | import org.eclipse.emf.ecore.InternalEObject; |
| 23 | |
| 24 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 25 | |
| 26 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 27 | |
| 28 | /** |
| 29 | * <!-- begin-user-doc --> |
| 30 | * An implementation of the model object '<em><b>Tuple Literal Part</b></em>'. |
| 31 | * <!-- end-user-doc --> |
| 32 | * <p> |
| 33 | * The following features are implemented: |
| 34 | * <ul> |
| 35 | * <li>{@link EssentialOCL.impl.TupleLiteralPartImpl#getAttribute <em>Attribute</em>}</li> |
| 36 | * <li>{@link EssentialOCL.impl.TupleLiteralPartImpl#getTupleLiteralExp <em>Tuple Literal Exp</em>}</li> |
| 37 | * <li>{@link EssentialOCL.impl.TupleLiteralPartImpl#getValue <em>Value</em>}</li> |
| 38 | * </ul> |
| 39 | * </p> |
| 40 | * |
| 41 | * @generated |
| 42 | */ |
| 43 | public class TupleLiteralPartImpl extends TypedElementImpl implements TupleLiteralPart { |
| 44 | /** |
| 45 | * The cached value of the '{@link #getAttribute() <em>Attribute</em>}' reference. |
| 46 | * <!-- begin-user-doc --> |
| 47 | * <!-- end-user-doc --> |
| 48 | * @see #getAttribute() |
| 49 | * @generated |
| 50 | * @ordered |
| 51 | */ |
| 52 | protected Property attribute; |
| 53 | |
| 54 | /** |
| 55 | * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference. |
| 56 | * <!-- begin-user-doc --> |
| 57 | * <!-- end-user-doc --> |
| 58 | * @see #getValue() |
| 59 | * @generated |
| 60 | * @ordered |
| 61 | */ |
| 62 | protected OclExpression value; |
| 63 | |
| 64 | /** |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @generated |
| 68 | */ |
| 69 | protected TupleLiteralPartImpl() { |
| 70 | super(); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * <!-- begin-user-doc --> |
| 75 | * <!-- end-user-doc --> |
| 76 | * @generated |
| 77 | */ |
| 78 | @Override |
| 79 | protected EClass eStaticClass() { |
| 80 | return EssentialOCLPackage.Literals.TUPLE_LITERAL_PART; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * <!-- begin-user-doc --> |
| 85 | * <!-- end-user-doc --> |
| 86 | * @generated |
| 87 | */ |
| 88 | public Property getAttribute() { |
| 89 | if (attribute != null && attribute.eIsProxy()) { |
| 90 | InternalEObject oldAttribute = (InternalEObject)attribute; |
| 91 | attribute = (Property)eResolveProxy(oldAttribute); |
| 92 | if (attribute != oldAttribute) { |
| 93 | if (eNotificationRequired()) |
| 94 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, EssentialOCLPackage.TUPLE_LITERAL_PART__ATTRIBUTE, oldAttribute, attribute)); |
| 95 | } |
| 96 | } |
| 97 | return attribute; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * <!-- begin-user-doc --> |
| 102 | * <!-- end-user-doc --> |
| 103 | * @generated |
| 104 | */ |
| 105 | public Property basicGetAttribute() { |
| 106 | return attribute; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * <!-- begin-user-doc --> |
| 111 | * <!-- end-user-doc --> |
| 112 | * @generated |
| 113 | */ |
| 114 | public void setAttribute(Property newAttribute) { |
| 115 | Property oldAttribute = attribute; |
| 116 | attribute = newAttribute; |
| 117 | if (eNotificationRequired()) |
| 118 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.TUPLE_LITERAL_PART__ATTRIBUTE, oldAttribute, attribute)); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * <!-- begin-user-doc --> |
| 123 | * <!-- end-user-doc --> |
| 124 | * @generated |
| 125 | */ |
| 126 | public TupleLiteralExp getTupleLiteralExp() { |
| 127 | if (eContainerFeatureID() != EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP) return null; |
| 128 | return (TupleLiteralExp)eContainer(); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | public NotificationChain basicSetTupleLiteralExp(TupleLiteralExp newTupleLiteralExp, NotificationChain msgs) { |
| 137 | msgs = eBasicSetContainer((InternalEObject)newTupleLiteralExp, EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP, msgs); |
| 138 | return msgs; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * <!-- begin-user-doc --> |
| 143 | * <!-- end-user-doc --> |
| 144 | * @generated |
| 145 | */ |
| 146 | public void setTupleLiteralExp(TupleLiteralExp newTupleLiteralExp) { |
| 147 | if (newTupleLiteralExp != eInternalContainer() || (eContainerFeatureID() != EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP && newTupleLiteralExp != null)) { |
| 148 | if (EcoreUtil.isAncestor(this, newTupleLiteralExp)) |
| 149 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 150 | NotificationChain msgs = null; |
| 151 | if (eInternalContainer() != null) |
| 152 | msgs = eBasicRemoveFromContainer(msgs); |
| 153 | if (newTupleLiteralExp != null) |
| 154 | msgs = ((InternalEObject)newTupleLiteralExp).eInverseAdd(this, EssentialOCLPackage.TUPLE_LITERAL_EXP__PART, TupleLiteralExp.class, msgs); |
| 155 | msgs = basicSetTupleLiteralExp(newTupleLiteralExp, msgs); |
| 156 | if (msgs != null) msgs.dispatch(); |
| 157 | } |
| 158 | else if (eNotificationRequired()) |
| 159 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP, newTupleLiteralExp, newTupleLiteralExp)); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * <!-- begin-user-doc --> |
| 164 | * <!-- end-user-doc --> |
| 165 | * @generated |
| 166 | */ |
| 167 | public OclExpression getValue() { |
| 168 | return value; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * <!-- begin-user-doc --> |
| 173 | * <!-- end-user-doc --> |
| 174 | * @generated |
| 175 | */ |
| 176 | public NotificationChain basicSetValue(OclExpression newValue, NotificationChain msgs) { |
| 177 | OclExpression oldValue = value; |
| 178 | value = newValue; |
| 179 | if (eNotificationRequired()) { |
| 180 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE, oldValue, newValue); |
| 181 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 182 | } |
| 183 | return msgs; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * <!-- begin-user-doc --> |
| 188 | * <!-- end-user-doc --> |
| 189 | * @generated |
| 190 | */ |
| 191 | public void setValue(OclExpression newValue) { |
| 192 | if (newValue != value) { |
| 193 | NotificationChain msgs = null; |
| 194 | if (value != null) |
| 195 | msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE, null, msgs); |
| 196 | if (newValue != null) |
| 197 | msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE, null, msgs); |
| 198 | msgs = basicSetValue(newValue, msgs); |
| 199 | if (msgs != null) msgs.dispatch(); |
| 200 | } |
| 201 | else if (eNotificationRequired()) |
| 202 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE, newValue, newValue)); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * <!-- begin-user-doc --> |
| 207 | * <!-- end-user-doc --> |
| 208 | * @generated |
| 209 | */ |
| 210 | @Override |
| 211 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 212 | switch (featureID) { |
| 213 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 214 | if (eInternalContainer() != null) |
| 215 | msgs = eBasicRemoveFromContainer(msgs); |
| 216 | return basicSetTupleLiteralExp((TupleLiteralExp)otherEnd, msgs); |
| 217 | } |
| 218 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * <!-- begin-user-doc --> |
| 223 | * <!-- end-user-doc --> |
| 224 | * @generated |
| 225 | */ |
| 226 | @Override |
| 227 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 228 | switch (featureID) { |
| 229 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 230 | return basicSetTupleLiteralExp(null, msgs); |
| 231 | case EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE: |
| 232 | return basicSetValue(null, msgs); |
| 233 | } |
| 234 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * <!-- begin-user-doc --> |
| 239 | * <!-- end-user-doc --> |
| 240 | * @generated |
| 241 | */ |
| 242 | @Override |
| 243 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 244 | switch (eContainerFeatureID()) { |
| 245 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 246 | return eInternalContainer().eInverseRemove(this, EssentialOCLPackage.TUPLE_LITERAL_EXP__PART, TupleLiteralExp.class, msgs); |
| 247 | } |
| 248 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * <!-- begin-user-doc --> |
| 253 | * <!-- end-user-doc --> |
| 254 | * @generated |
| 255 | */ |
| 256 | @Override |
| 257 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 258 | switch (featureID) { |
| 259 | case EssentialOCLPackage.TUPLE_LITERAL_PART__ATTRIBUTE: |
| 260 | if (resolve) return getAttribute(); |
| 261 | return basicGetAttribute(); |
| 262 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 263 | return getTupleLiteralExp(); |
| 264 | case EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE: |
| 265 | return getValue(); |
| 266 | } |
| 267 | return super.eGet(featureID, resolve, coreType); |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * <!-- begin-user-doc --> |
| 272 | * <!-- end-user-doc --> |
| 273 | * @generated |
| 274 | */ |
| 275 | @Override |
| 276 | public void eSet(int featureID, Object newValue) { |
| 277 | switch (featureID) { |
| 278 | case EssentialOCLPackage.TUPLE_LITERAL_PART__ATTRIBUTE: |
| 279 | setAttribute((Property)newValue); |
| 280 | return; |
| 281 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 282 | setTupleLiteralExp((TupleLiteralExp)newValue); |
| 283 | return; |
| 284 | case EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE: |
| 285 | setValue((OclExpression)newValue); |
| 286 | return; |
| 287 | } |
| 288 | super.eSet(featureID, newValue); |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * <!-- begin-user-doc --> |
| 293 | * <!-- end-user-doc --> |
| 294 | * @generated |
| 295 | */ |
| 296 | @Override |
| 297 | public void eUnset(int featureID) { |
| 298 | switch (featureID) { |
| 299 | case EssentialOCLPackage.TUPLE_LITERAL_PART__ATTRIBUTE: |
| 300 | setAttribute((Property)null); |
| 301 | return; |
| 302 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 303 | setTupleLiteralExp((TupleLiteralExp)null); |
| 304 | return; |
| 305 | case EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE: |
| 306 | setValue((OclExpression)null); |
| 307 | return; |
| 308 | } |
| 309 | super.eUnset(featureID); |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * <!-- begin-user-doc --> |
| 314 | * <!-- end-user-doc --> |
| 315 | * @generated |
| 316 | */ |
| 317 | @Override |
| 318 | public boolean eIsSet(int featureID) { |
| 319 | switch (featureID) { |
| 320 | case EssentialOCLPackage.TUPLE_LITERAL_PART__ATTRIBUTE: |
| 321 | return attribute != null; |
| 322 | case EssentialOCLPackage.TUPLE_LITERAL_PART__TUPLE_LITERAL_EXP: |
| 323 | return getTupleLiteralExp() != null; |
| 324 | case EssentialOCLPackage.TUPLE_LITERAL_PART__VALUE: |
| 325 | return value != null; |
| 326 | } |
| 327 | return super.eIsSet(featureID); |
| 328 | } |
| 329 | |
| 330 | } //TupleLiteralPartImpl |