| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package QVTTemplate.impl; |
| 8 | |
| 9 | import EMOF.Property; |
| 10 | |
| 11 | import EMOF.impl.ElementImpl; |
| 12 | |
| 13 | import EssentialOCL.OclExpression; |
| 14 | |
| 15 | import QVTTemplate.ObjectTemplateExp; |
| 16 | import QVTTemplate.PropertyTemplateItem; |
| 17 | import QVTTemplate.QVTTemplatePackage; |
| 18 | |
| 19 | import org.eclipse.emf.common.notify.Notification; |
| 20 | import org.eclipse.emf.common.notify.NotificationChain; |
| 21 | |
| 22 | import org.eclipse.emf.ecore.EClass; |
| 23 | import org.eclipse.emf.ecore.InternalEObject; |
| 24 | |
| 25 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 26 | |
| 27 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 28 | |
| 29 | /** |
| 30 | * <!-- begin-user-doc --> |
| 31 | * An implementation of the model object '<em><b>Property Template Item</b></em>'. |
| 32 | * <!-- end-user-doc --> |
| 33 | * <p> |
| 34 | * The following features are implemented: |
| 35 | * <ul> |
| 36 | * <li>{@link QVTTemplate.impl.PropertyTemplateItemImpl#getIsOpposite <em>Is Opposite</em>}</li> |
| 37 | * <li>{@link QVTTemplate.impl.PropertyTemplateItemImpl#getObjContainer <em>Obj Container</em>}</li> |
| 38 | * <li>{@link QVTTemplate.impl.PropertyTemplateItemImpl#getReferredProperty <em>Referred Property</em>}</li> |
| 39 | * <li>{@link QVTTemplate.impl.PropertyTemplateItemImpl#getValue <em>Value</em>}</li> |
| 40 | * </ul> |
| 41 | * </p> |
| 42 | * |
| 43 | * @generated |
| 44 | */ |
| 45 | public class PropertyTemplateItemImpl extends ElementImpl implements PropertyTemplateItem { |
| 46 | /** |
| 47 | * The default value of the '{@link #getIsOpposite() <em>Is Opposite</em>}' attribute. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @see #getIsOpposite() |
| 51 | * @generated |
| 52 | * @ordered |
| 53 | */ |
| 54 | protected static final Boolean IS_OPPOSITE_EDEFAULT = Boolean.FALSE; |
| 55 | |
| 56 | /** |
| 57 | * The cached value of the '{@link #getIsOpposite() <em>Is Opposite</em>}' attribute. |
| 58 | * <!-- begin-user-doc --> |
| 59 | * <!-- end-user-doc --> |
| 60 | * @see #getIsOpposite() |
| 61 | * @generated |
| 62 | * @ordered |
| 63 | */ |
| 64 | protected Boolean isOpposite = IS_OPPOSITE_EDEFAULT; |
| 65 | |
| 66 | /** |
| 67 | * The cached value of the '{@link #getReferredProperty() <em>Referred Property</em>}' reference. |
| 68 | * <!-- begin-user-doc --> |
| 69 | * <!-- end-user-doc --> |
| 70 | * @see #getReferredProperty() |
| 71 | * @generated |
| 72 | * @ordered |
| 73 | */ |
| 74 | protected Property referredProperty; |
| 75 | |
| 76 | /** |
| 77 | * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference. |
| 78 | * <!-- begin-user-doc --> |
| 79 | * <!-- end-user-doc --> |
| 80 | * @see #getValue() |
| 81 | * @generated |
| 82 | * @ordered |
| 83 | */ |
| 84 | protected OclExpression value; |
| 85 | |
| 86 | /** |
| 87 | * <!-- begin-user-doc --> |
| 88 | * <!-- end-user-doc --> |
| 89 | * @generated |
| 90 | */ |
| 91 | protected PropertyTemplateItemImpl() { |
| 92 | super(); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * <!-- begin-user-doc --> |
| 97 | * <!-- end-user-doc --> |
| 98 | * @generated |
| 99 | */ |
| 100 | @Override |
| 101 | protected EClass eStaticClass() { |
| 102 | return QVTTemplatePackage.Literals.PROPERTY_TEMPLATE_ITEM; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * <!-- begin-user-doc --> |
| 107 | * <!-- end-user-doc --> |
| 108 | * @generated |
| 109 | */ |
| 110 | public Boolean getIsOpposite() { |
| 111 | return isOpposite; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * <!-- begin-user-doc --> |
| 116 | * <!-- end-user-doc --> |
| 117 | * @generated |
| 118 | */ |
| 119 | public void setIsOpposite(Boolean newIsOpposite) { |
| 120 | Boolean oldIsOpposite = isOpposite; |
| 121 | isOpposite = newIsOpposite; |
| 122 | if (eNotificationRequired()) |
| 123 | eNotify(new ENotificationImpl(this, Notification.SET, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__IS_OPPOSITE, oldIsOpposite, isOpposite)); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | public ObjectTemplateExp getObjContainer() { |
| 132 | if (eContainerFeatureID() != QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER) return null; |
| 133 | return (ObjectTemplateExp)eContainer(); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * <!-- begin-user-doc --> |
| 138 | * <!-- end-user-doc --> |
| 139 | * @generated |
| 140 | */ |
| 141 | public NotificationChain basicSetObjContainer(ObjectTemplateExp newObjContainer, NotificationChain msgs) { |
| 142 | msgs = eBasicSetContainer((InternalEObject)newObjContainer, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER, msgs); |
| 143 | return msgs; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * <!-- begin-user-doc --> |
| 148 | * <!-- end-user-doc --> |
| 149 | * @generated |
| 150 | */ |
| 151 | public void setObjContainer(ObjectTemplateExp newObjContainer) { |
| 152 | if (newObjContainer != eInternalContainer() || (eContainerFeatureID() != QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER && newObjContainer != null)) { |
| 153 | if (EcoreUtil.isAncestor(this, newObjContainer)) |
| 154 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 155 | NotificationChain msgs = null; |
| 156 | if (eInternalContainer() != null) |
| 157 | msgs = eBasicRemoveFromContainer(msgs); |
| 158 | if (newObjContainer != null) |
| 159 | msgs = ((InternalEObject)newObjContainer).eInverseAdd(this, QVTTemplatePackage.OBJECT_TEMPLATE_EXP__PART, ObjectTemplateExp.class, msgs); |
| 160 | msgs = basicSetObjContainer(newObjContainer, msgs); |
| 161 | if (msgs != null) msgs.dispatch(); |
| 162 | } |
| 163 | else if (eNotificationRequired()) |
| 164 | eNotify(new ENotificationImpl(this, Notification.SET, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER, newObjContainer, newObjContainer)); |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * <!-- begin-user-doc --> |
| 169 | * <!-- end-user-doc --> |
| 170 | * @generated |
| 171 | */ |
| 172 | public Property getReferredProperty() { |
| 173 | if (referredProperty != null && referredProperty.eIsProxy()) { |
| 174 | InternalEObject oldReferredProperty = (InternalEObject)referredProperty; |
| 175 | referredProperty = (Property)eResolveProxy(oldReferredProperty); |
| 176 | if (referredProperty != oldReferredProperty) { |
| 177 | if (eNotificationRequired()) |
| 178 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__REFERRED_PROPERTY, oldReferredProperty, referredProperty)); |
| 179 | } |
| 180 | } |
| 181 | return referredProperty; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * <!-- begin-user-doc --> |
| 186 | * <!-- end-user-doc --> |
| 187 | * @generated |
| 188 | */ |
| 189 | public Property basicGetReferredProperty() { |
| 190 | return referredProperty; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * <!-- begin-user-doc --> |
| 195 | * <!-- end-user-doc --> |
| 196 | * @generated |
| 197 | */ |
| 198 | public void setReferredProperty(Property newReferredProperty) { |
| 199 | Property oldReferredProperty = referredProperty; |
| 200 | referredProperty = newReferredProperty; |
| 201 | if (eNotificationRequired()) |
| 202 | eNotify(new ENotificationImpl(this, Notification.SET, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__REFERRED_PROPERTY, oldReferredProperty, referredProperty)); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * <!-- begin-user-doc --> |
| 207 | * <!-- end-user-doc --> |
| 208 | * @generated |
| 209 | */ |
| 210 | public OclExpression getValue() { |
| 211 | return value; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * <!-- begin-user-doc --> |
| 216 | * <!-- end-user-doc --> |
| 217 | * @generated |
| 218 | */ |
| 219 | public NotificationChain basicSetValue(OclExpression newValue, NotificationChain msgs) { |
| 220 | OclExpression oldValue = value; |
| 221 | value = newValue; |
| 222 | if (eNotificationRequired()) { |
| 223 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE, oldValue, newValue); |
| 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 setValue(OclExpression newValue) { |
| 235 | if (newValue != value) { |
| 236 | NotificationChain msgs = null; |
| 237 | if (value != null) |
| 238 | msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE, null, msgs); |
| 239 | if (newValue != null) |
| 240 | msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE, null, msgs); |
| 241 | msgs = basicSetValue(newValue, msgs); |
| 242 | if (msgs != null) msgs.dispatch(); |
| 243 | } |
| 244 | else if (eNotificationRequired()) |
| 245 | eNotify(new ENotificationImpl(this, Notification.SET, QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE, newValue, newValue)); |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * <!-- begin-user-doc --> |
| 250 | * <!-- end-user-doc --> |
| 251 | * @generated |
| 252 | */ |
| 253 | @Override |
| 254 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 255 | switch (featureID) { |
| 256 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 257 | if (eInternalContainer() != null) |
| 258 | msgs = eBasicRemoveFromContainer(msgs); |
| 259 | return basicSetObjContainer((ObjectTemplateExp)otherEnd, msgs); |
| 260 | } |
| 261 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * <!-- begin-user-doc --> |
| 266 | * <!-- end-user-doc --> |
| 267 | * @generated |
| 268 | */ |
| 269 | @Override |
| 270 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 271 | switch (featureID) { |
| 272 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 273 | return basicSetObjContainer(null, msgs); |
| 274 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE: |
| 275 | return basicSetValue(null, msgs); |
| 276 | } |
| 277 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * <!-- begin-user-doc --> |
| 282 | * <!-- end-user-doc --> |
| 283 | * @generated |
| 284 | */ |
| 285 | @Override |
| 286 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 287 | switch (eContainerFeatureID()) { |
| 288 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 289 | return eInternalContainer().eInverseRemove(this, QVTTemplatePackage.OBJECT_TEMPLATE_EXP__PART, ObjectTemplateExp.class, msgs); |
| 290 | } |
| 291 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * <!-- begin-user-doc --> |
| 296 | * <!-- end-user-doc --> |
| 297 | * @generated |
| 298 | */ |
| 299 | @Override |
| 300 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 301 | switch (featureID) { |
| 302 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__IS_OPPOSITE: |
| 303 | return getIsOpposite(); |
| 304 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 305 | return getObjContainer(); |
| 306 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__REFERRED_PROPERTY: |
| 307 | if (resolve) return getReferredProperty(); |
| 308 | return basicGetReferredProperty(); |
| 309 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE: |
| 310 | return getValue(); |
| 311 | } |
| 312 | return super.eGet(featureID, resolve, coreType); |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * <!-- begin-user-doc --> |
| 317 | * <!-- end-user-doc --> |
| 318 | * @generated |
| 319 | */ |
| 320 | @Override |
| 321 | public void eSet(int featureID, Object newValue) { |
| 322 | switch (featureID) { |
| 323 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__IS_OPPOSITE: |
| 324 | setIsOpposite((Boolean)newValue); |
| 325 | return; |
| 326 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 327 | setObjContainer((ObjectTemplateExp)newValue); |
| 328 | return; |
| 329 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__REFERRED_PROPERTY: |
| 330 | setReferredProperty((Property)newValue); |
| 331 | return; |
| 332 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE: |
| 333 | setValue((OclExpression)newValue); |
| 334 | return; |
| 335 | } |
| 336 | super.eSet(featureID, newValue); |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * <!-- begin-user-doc --> |
| 341 | * <!-- end-user-doc --> |
| 342 | * @generated |
| 343 | */ |
| 344 | @Override |
| 345 | public void eUnset(int featureID) { |
| 346 | switch (featureID) { |
| 347 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__IS_OPPOSITE: |
| 348 | setIsOpposite(IS_OPPOSITE_EDEFAULT); |
| 349 | return; |
| 350 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 351 | setObjContainer((ObjectTemplateExp)null); |
| 352 | return; |
| 353 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__REFERRED_PROPERTY: |
| 354 | setReferredProperty((Property)null); |
| 355 | return; |
| 356 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE: |
| 357 | setValue((OclExpression)null); |
| 358 | return; |
| 359 | } |
| 360 | super.eUnset(featureID); |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * <!-- begin-user-doc --> |
| 365 | * <!-- end-user-doc --> |
| 366 | * @generated |
| 367 | */ |
| 368 | @Override |
| 369 | public boolean eIsSet(int featureID) { |
| 370 | switch (featureID) { |
| 371 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__IS_OPPOSITE: |
| 372 | return IS_OPPOSITE_EDEFAULT == null ? isOpposite != null : !IS_OPPOSITE_EDEFAULT.equals(isOpposite); |
| 373 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__OBJ_CONTAINER: |
| 374 | return getObjContainer() != null; |
| 375 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__REFERRED_PROPERTY: |
| 376 | return referredProperty != null; |
| 377 | case QVTTemplatePackage.PROPERTY_TEMPLATE_ITEM__VALUE: |
| 378 | return value != null; |
| 379 | } |
| 380 | return super.eIsSet(featureID); |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * <!-- begin-user-doc --> |
| 385 | * <!-- end-user-doc --> |
| 386 | * @generated |
| 387 | */ |
| 388 | @Override |
| 389 | public String toString() { |
| 390 | if (eIsProxy()) return super.toString(); |
| 391 | |
| 392 | StringBuffer result = new StringBuffer(super.toString()); |
| 393 | result.append(" (isOpposite: "); |
| 394 | result.append(isOpposite); |
| 395 | result.append(')'); |
| 396 | return result.toString(); |
| 397 | } |
| 398 | |
| 399 | } //PropertyTemplateItemImpl |