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