| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package QVTBase.impl; |
| 8 | |
| 9 | import EMOF.impl.NamedElementImpl; |
| 10 | |
| 11 | import QVTBase.Domain; |
| 12 | import QVTBase.QVTBasePackage; |
| 13 | import QVTBase.Rule; |
| 14 | import QVTBase.Transformation; |
| 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.EObjectContainmentWithInverseEList; |
| 29 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 30 | import org.eclipse.emf.ecore.util.InternalEList; |
| 31 | |
| 32 | /** |
| 33 | * <!-- begin-user-doc --> |
| 34 | * An implementation of the model object '<em><b>Rule</b></em>'. |
| 35 | * <!-- end-user-doc --> |
| 36 | * <p> |
| 37 | * The following features are implemented: |
| 38 | * <ul> |
| 39 | * <li>{@link QVTBase.impl.RuleImpl#getDomain <em>Domain</em>}</li> |
| 40 | * <li>{@link QVTBase.impl.RuleImpl#getOverrides <em>Overrides</em>}</li> |
| 41 | * <li>{@link QVTBase.impl.RuleImpl#getTransformation <em>Transformation</em>}</li> |
| 42 | * </ul> |
| 43 | * </p> |
| 44 | * |
| 45 | * @generated |
| 46 | */ |
| 47 | public abstract class RuleImpl extends NamedElementImpl implements Rule { |
| 48 | /** |
| 49 | * The cached value of the '{@link #getDomain() <em>Domain</em>}' containment reference list. |
| 50 | * <!-- begin-user-doc --> |
| 51 | * <!-- end-user-doc --> |
| 52 | * @see #getDomain() |
| 53 | * @generated |
| 54 | * @ordered |
| 55 | */ |
| 56 | protected EList<Domain> domain; |
| 57 | |
| 58 | /** |
| 59 | * The cached value of the '{@link #getOverrides() <em>Overrides</em>}' reference. |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @see #getOverrides() |
| 63 | * @generated |
| 64 | * @ordered |
| 65 | */ |
| 66 | protected Rule overrides; |
| 67 | |
| 68 | /** |
| 69 | * <!-- begin-user-doc --> |
| 70 | * <!-- end-user-doc --> |
| 71 | * @generated |
| 72 | */ |
| 73 | protected RuleImpl() { |
| 74 | super(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * <!-- begin-user-doc --> |
| 79 | * <!-- end-user-doc --> |
| 80 | * @generated |
| 81 | */ |
| 82 | @Override |
| 83 | protected EClass eStaticClass() { |
| 84 | return QVTBasePackage.Literals.RULE; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * <!-- begin-user-doc --> |
| 89 | * <!-- end-user-doc --> |
| 90 | * @generated |
| 91 | */ |
| 92 | public EList<Domain> getDomain() { |
| 93 | if (domain == null) { |
| 94 | domain = new EObjectContainmentWithInverseEList<Domain>(Domain.class, this, QVTBasePackage.RULE__DOMAIN, QVTBasePackage.DOMAIN__RULE); |
| 95 | } |
| 96 | return domain; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * <!-- begin-user-doc --> |
| 101 | * <!-- end-user-doc --> |
| 102 | * @generated |
| 103 | */ |
| 104 | public Rule getOverrides() { |
| 105 | if (overrides != null && overrides.eIsProxy()) { |
| 106 | InternalEObject oldOverrides = (InternalEObject)overrides; |
| 107 | overrides = (Rule)eResolveProxy(oldOverrides); |
| 108 | if (overrides != oldOverrides) { |
| 109 | if (eNotificationRequired()) |
| 110 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QVTBasePackage.RULE__OVERRIDES, oldOverrides, overrides)); |
| 111 | } |
| 112 | } |
| 113 | return overrides; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | public Rule basicGetOverrides() { |
| 122 | return overrides; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * <!-- begin-user-doc --> |
| 127 | * <!-- end-user-doc --> |
| 128 | * @generated |
| 129 | */ |
| 130 | public void setOverrides(Rule newOverrides) { |
| 131 | Rule oldOverrides = overrides; |
| 132 | overrides = newOverrides; |
| 133 | if (eNotificationRequired()) |
| 134 | eNotify(new ENotificationImpl(this, Notification.SET, QVTBasePackage.RULE__OVERRIDES, oldOverrides, overrides)); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * <!-- begin-user-doc --> |
| 139 | * <!-- end-user-doc --> |
| 140 | * @generated |
| 141 | */ |
| 142 | public Transformation getTransformation() { |
| 143 | if (eContainerFeatureID() != QVTBasePackage.RULE__TRANSFORMATION) return null; |
| 144 | return (Transformation)eContainer(); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * <!-- begin-user-doc --> |
| 149 | * <!-- end-user-doc --> |
| 150 | * @generated |
| 151 | */ |
| 152 | public NotificationChain basicSetTransformation(Transformation newTransformation, NotificationChain msgs) { |
| 153 | msgs = eBasicSetContainer((InternalEObject)newTransformation, QVTBasePackage.RULE__TRANSFORMATION, msgs); |
| 154 | return msgs; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * <!-- begin-user-doc --> |
| 159 | * <!-- end-user-doc --> |
| 160 | * @generated |
| 161 | */ |
| 162 | public void setTransformation(Transformation newTransformation) { |
| 163 | if (newTransformation != eInternalContainer() || (eContainerFeatureID() != QVTBasePackage.RULE__TRANSFORMATION && newTransformation != null)) { |
| 164 | if (EcoreUtil.isAncestor(this, newTransformation)) |
| 165 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 166 | NotificationChain msgs = null; |
| 167 | if (eInternalContainer() != null) |
| 168 | msgs = eBasicRemoveFromContainer(msgs); |
| 169 | if (newTransformation != null) |
| 170 | msgs = ((InternalEObject)newTransformation).eInverseAdd(this, QVTBasePackage.TRANSFORMATION__RULE, Transformation.class, msgs); |
| 171 | msgs = basicSetTransformation(newTransformation, msgs); |
| 172 | if (msgs != null) msgs.dispatch(); |
| 173 | } |
| 174 | else if (eNotificationRequired()) |
| 175 | eNotify(new ENotificationImpl(this, Notification.SET, QVTBasePackage.RULE__TRANSFORMATION, newTransformation, newTransformation)); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * <!-- begin-user-doc --> |
| 180 | * <!-- end-user-doc --> |
| 181 | * @generated |
| 182 | */ |
| 183 | @SuppressWarnings("unchecked") |
| 184 | @Override |
| 185 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 186 | switch (featureID) { |
| 187 | case QVTBasePackage.RULE__DOMAIN: |
| 188 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getDomain()).basicAdd(otherEnd, msgs); |
| 189 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 190 | if (eInternalContainer() != null) |
| 191 | msgs = eBasicRemoveFromContainer(msgs); |
| 192 | return basicSetTransformation((Transformation)otherEnd, msgs); |
| 193 | } |
| 194 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * <!-- begin-user-doc --> |
| 199 | * <!-- end-user-doc --> |
| 200 | * @generated |
| 201 | */ |
| 202 | @Override |
| 203 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 204 | switch (featureID) { |
| 205 | case QVTBasePackage.RULE__DOMAIN: |
| 206 | return ((InternalEList<?>)getDomain()).basicRemove(otherEnd, msgs); |
| 207 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 208 | return basicSetTransformation(null, msgs); |
| 209 | } |
| 210 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * <!-- begin-user-doc --> |
| 215 | * <!-- end-user-doc --> |
| 216 | * @generated |
| 217 | */ |
| 218 | @Override |
| 219 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 220 | switch (eContainerFeatureID()) { |
| 221 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 222 | return eInternalContainer().eInverseRemove(this, QVTBasePackage.TRANSFORMATION__RULE, Transformation.class, msgs); |
| 223 | } |
| 224 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * <!-- begin-user-doc --> |
| 229 | * <!-- end-user-doc --> |
| 230 | * @generated |
| 231 | */ |
| 232 | @Override |
| 233 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 234 | switch (featureID) { |
| 235 | case QVTBasePackage.RULE__DOMAIN: |
| 236 | return getDomain(); |
| 237 | case QVTBasePackage.RULE__OVERRIDES: |
| 238 | if (resolve) return getOverrides(); |
| 239 | return basicGetOverrides(); |
| 240 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 241 | return getTransformation(); |
| 242 | } |
| 243 | return super.eGet(featureID, resolve, coreType); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * <!-- begin-user-doc --> |
| 248 | * <!-- end-user-doc --> |
| 249 | * @generated |
| 250 | */ |
| 251 | @SuppressWarnings("unchecked") |
| 252 | @Override |
| 253 | public void eSet(int featureID, Object newValue) { |
| 254 | switch (featureID) { |
| 255 | case QVTBasePackage.RULE__DOMAIN: |
| 256 | getDomain().clear(); |
| 257 | getDomain().addAll((Collection<? extends Domain>)newValue); |
| 258 | return; |
| 259 | case QVTBasePackage.RULE__OVERRIDES: |
| 260 | setOverrides((Rule)newValue); |
| 261 | return; |
| 262 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 263 | setTransformation((Transformation)newValue); |
| 264 | return; |
| 265 | } |
| 266 | super.eSet(featureID, newValue); |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * <!-- begin-user-doc --> |
| 271 | * <!-- end-user-doc --> |
| 272 | * @generated |
| 273 | */ |
| 274 | @Override |
| 275 | public void eUnset(int featureID) { |
| 276 | switch (featureID) { |
| 277 | case QVTBasePackage.RULE__DOMAIN: |
| 278 | getDomain().clear(); |
| 279 | return; |
| 280 | case QVTBasePackage.RULE__OVERRIDES: |
| 281 | setOverrides((Rule)null); |
| 282 | return; |
| 283 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 284 | setTransformation((Transformation)null); |
| 285 | return; |
| 286 | } |
| 287 | super.eUnset(featureID); |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * <!-- begin-user-doc --> |
| 292 | * <!-- end-user-doc --> |
| 293 | * @generated |
| 294 | */ |
| 295 | @Override |
| 296 | public boolean eIsSet(int featureID) { |
| 297 | switch (featureID) { |
| 298 | case QVTBasePackage.RULE__DOMAIN: |
| 299 | return domain != null && !domain.isEmpty(); |
| 300 | case QVTBasePackage.RULE__OVERRIDES: |
| 301 | return overrides != null; |
| 302 | case QVTBasePackage.RULE__TRANSFORMATION: |
| 303 | return getTransformation() != null; |
| 304 | } |
| 305 | return super.eIsSet(featureID); |
| 306 | } |
| 307 | |
| 308 | } //RuleImpl |