| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EssentialOCL.impl; |
| 8 | |
| 9 | import EssentialOCL.EssentialOCLPackage; |
| 10 | import EssentialOCL.LoopExp; |
| 11 | import EssentialOCL.OclExpression; |
| 12 | import EssentialOCL.Variable; |
| 13 | |
| 14 | import java.util.Collection; |
| 15 | |
| 16 | import org.eclipse.emf.common.notify.Notification; |
| 17 | import org.eclipse.emf.common.notify.NotificationChain; |
| 18 | |
| 19 | import org.eclipse.emf.common.util.EList; |
| 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.EObjectContainmentEList; |
| 27 | import org.eclipse.emf.ecore.util.InternalEList; |
| 28 | |
| 29 | /** |
| 30 | * <!-- begin-user-doc --> |
| 31 | * An implementation of the model object '<em><b>Loop Exp</b></em>'. |
| 32 | * <!-- end-user-doc --> |
| 33 | * <p> |
| 34 | * The following features are implemented: |
| 35 | * <ul> |
| 36 | * <li>{@link EssentialOCL.impl.LoopExpImpl#getBody <em>Body</em>}</li> |
| 37 | * <li>{@link EssentialOCL.impl.LoopExpImpl#getIterator <em>Iterator</em>}</li> |
| 38 | * </ul> |
| 39 | * </p> |
| 40 | * |
| 41 | * @generated |
| 42 | */ |
| 43 | public abstract class LoopExpImpl extends CallExpImpl implements LoopExp { |
| 44 | /** |
| 45 | * The cached value of the '{@link #getBody() <em>Body</em>}' containment reference. |
| 46 | * <!-- begin-user-doc --> |
| 47 | * <!-- end-user-doc --> |
| 48 | * @see #getBody() |
| 49 | * @generated |
| 50 | * @ordered |
| 51 | */ |
| 52 | protected OclExpression body; |
| 53 | |
| 54 | /** |
| 55 | * The cached value of the '{@link #getIterator() <em>Iterator</em>}' containment reference list. |
| 56 | * <!-- begin-user-doc --> |
| 57 | * <!-- end-user-doc --> |
| 58 | * @see #getIterator() |
| 59 | * @generated |
| 60 | * @ordered |
| 61 | */ |
| 62 | protected EList<Variable> iterator; |
| 63 | |
| 64 | /** |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @generated |
| 68 | */ |
| 69 | protected LoopExpImpl() { |
| 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.LOOP_EXP; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * <!-- begin-user-doc --> |
| 85 | * <!-- end-user-doc --> |
| 86 | * @generated |
| 87 | */ |
| 88 | public OclExpression getBody() { |
| 89 | return body; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | public NotificationChain basicSetBody(OclExpression newBody, NotificationChain msgs) { |
| 98 | OclExpression oldBody = body; |
| 99 | body = newBody; |
| 100 | if (eNotificationRequired()) { |
| 101 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.LOOP_EXP__BODY, oldBody, newBody); |
| 102 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 103 | } |
| 104 | return msgs; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * <!-- begin-user-doc --> |
| 109 | * <!-- end-user-doc --> |
| 110 | * @generated |
| 111 | */ |
| 112 | public void setBody(OclExpression newBody) { |
| 113 | if (newBody != body) { |
| 114 | NotificationChain msgs = null; |
| 115 | if (body != null) |
| 116 | msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.LOOP_EXP__BODY, null, msgs); |
| 117 | if (newBody != null) |
| 118 | msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.LOOP_EXP__BODY, null, msgs); |
| 119 | msgs = basicSetBody(newBody, msgs); |
| 120 | if (msgs != null) msgs.dispatch(); |
| 121 | } |
| 122 | else if (eNotificationRequired()) |
| 123 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.LOOP_EXP__BODY, newBody, newBody)); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | public EList<Variable> getIterator() { |
| 132 | if (iterator == null) { |
| 133 | iterator = new EObjectContainmentEList<Variable>(Variable.class, this, EssentialOCLPackage.LOOP_EXP__ITERATOR); |
| 134 | } |
| 135 | return iterator; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * <!-- begin-user-doc --> |
| 140 | * <!-- end-user-doc --> |
| 141 | * @generated |
| 142 | */ |
| 143 | @Override |
| 144 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 145 | switch (featureID) { |
| 146 | case EssentialOCLPackage.LOOP_EXP__BODY: |
| 147 | return basicSetBody(null, msgs); |
| 148 | case EssentialOCLPackage.LOOP_EXP__ITERATOR: |
| 149 | return ((InternalEList<?>)getIterator()).basicRemove(otherEnd, msgs); |
| 150 | } |
| 151 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * <!-- begin-user-doc --> |
| 156 | * <!-- end-user-doc --> |
| 157 | * @generated |
| 158 | */ |
| 159 | @Override |
| 160 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 161 | switch (featureID) { |
| 162 | case EssentialOCLPackage.LOOP_EXP__BODY: |
| 163 | return getBody(); |
| 164 | case EssentialOCLPackage.LOOP_EXP__ITERATOR: |
| 165 | return getIterator(); |
| 166 | } |
| 167 | return super.eGet(featureID, resolve, coreType); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * <!-- begin-user-doc --> |
| 172 | * <!-- end-user-doc --> |
| 173 | * @generated |
| 174 | */ |
| 175 | @SuppressWarnings("unchecked") |
| 176 | @Override |
| 177 | public void eSet(int featureID, Object newValue) { |
| 178 | switch (featureID) { |
| 179 | case EssentialOCLPackage.LOOP_EXP__BODY: |
| 180 | setBody((OclExpression)newValue); |
| 181 | return; |
| 182 | case EssentialOCLPackage.LOOP_EXP__ITERATOR: |
| 183 | getIterator().clear(); |
| 184 | getIterator().addAll((Collection<? extends Variable>)newValue); |
| 185 | return; |
| 186 | } |
| 187 | super.eSet(featureID, newValue); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * <!-- begin-user-doc --> |
| 192 | * <!-- end-user-doc --> |
| 193 | * @generated |
| 194 | */ |
| 195 | @Override |
| 196 | public void eUnset(int featureID) { |
| 197 | switch (featureID) { |
| 198 | case EssentialOCLPackage.LOOP_EXP__BODY: |
| 199 | setBody((OclExpression)null); |
| 200 | return; |
| 201 | case EssentialOCLPackage.LOOP_EXP__ITERATOR: |
| 202 | getIterator().clear(); |
| 203 | return; |
| 204 | } |
| 205 | super.eUnset(featureID); |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * <!-- begin-user-doc --> |
| 210 | * <!-- end-user-doc --> |
| 211 | * @generated |
| 212 | */ |
| 213 | @Override |
| 214 | public boolean eIsSet(int featureID) { |
| 215 | switch (featureID) { |
| 216 | case EssentialOCLPackage.LOOP_EXP__BODY: |
| 217 | return body != null; |
| 218 | case EssentialOCLPackage.LOOP_EXP__ITERATOR: |
| 219 | return iterator != null && !iterator.isEmpty(); |
| 220 | } |
| 221 | return super.eIsSet(featureID); |
| 222 | } |
| 223 | |
| 224 | } //LoopExpImpl |