| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EssentialOCL.impl; |
| 8 | |
| 9 | import EssentialOCL.CollectionRange; |
| 10 | import EssentialOCL.EssentialOCLPackage; |
| 11 | import EssentialOCL.OclExpression; |
| 12 | |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.common.notify.NotificationChain; |
| 15 | |
| 16 | import org.eclipse.emf.ecore.EClass; |
| 17 | import org.eclipse.emf.ecore.InternalEObject; |
| 18 | |
| 19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 20 | |
| 21 | /** |
| 22 | * <!-- begin-user-doc --> |
| 23 | * An implementation of the model object '<em><b>Collection Range</b></em>'. |
| 24 | * <!-- end-user-doc --> |
| 25 | * <p> |
| 26 | * The following features are implemented: |
| 27 | * <ul> |
| 28 | * <li>{@link EssentialOCL.impl.CollectionRangeImpl#getFirst <em>First</em>}</li> |
| 29 | * <li>{@link EssentialOCL.impl.CollectionRangeImpl#getLast <em>Last</em>}</li> |
| 30 | * </ul> |
| 31 | * </p> |
| 32 | * |
| 33 | * @generated |
| 34 | */ |
| 35 | public class CollectionRangeImpl extends CollectionLiteralPartImpl implements CollectionRange { |
| 36 | /** |
| 37 | * The cached value of the '{@link #getFirst() <em>First</em>}' containment reference. |
| 38 | * <!-- begin-user-doc --> |
| 39 | * <!-- end-user-doc --> |
| 40 | * @see #getFirst() |
| 41 | * @generated |
| 42 | * @ordered |
| 43 | */ |
| 44 | protected OclExpression first; |
| 45 | |
| 46 | /** |
| 47 | * The cached value of the '{@link #getLast() <em>Last</em>}' containment reference. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @see #getLast() |
| 51 | * @generated |
| 52 | * @ordered |
| 53 | */ |
| 54 | protected OclExpression last; |
| 55 | |
| 56 | /** |
| 57 | * <!-- begin-user-doc --> |
| 58 | * <!-- end-user-doc --> |
| 59 | * @generated |
| 60 | */ |
| 61 | protected CollectionRangeImpl() { |
| 62 | super(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * <!-- begin-user-doc --> |
| 67 | * <!-- end-user-doc --> |
| 68 | * @generated |
| 69 | */ |
| 70 | @Override |
| 71 | protected EClass eStaticClass() { |
| 72 | return EssentialOCLPackage.Literals.COLLECTION_RANGE; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * <!-- begin-user-doc --> |
| 77 | * <!-- end-user-doc --> |
| 78 | * @generated |
| 79 | */ |
| 80 | public OclExpression getFirst() { |
| 81 | return first; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * <!-- begin-user-doc --> |
| 86 | * <!-- end-user-doc --> |
| 87 | * @generated |
| 88 | */ |
| 89 | public NotificationChain basicSetFirst(OclExpression newFirst, NotificationChain msgs) { |
| 90 | OclExpression oldFirst = first; |
| 91 | first = newFirst; |
| 92 | if (eNotificationRequired()) { |
| 93 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.COLLECTION_RANGE__FIRST, oldFirst, newFirst); |
| 94 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 95 | } |
| 96 | return msgs; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * <!-- begin-user-doc --> |
| 101 | * <!-- end-user-doc --> |
| 102 | * @generated |
| 103 | */ |
| 104 | public void setFirst(OclExpression newFirst) { |
| 105 | if (newFirst != first) { |
| 106 | NotificationChain msgs = null; |
| 107 | if (first != null) |
| 108 | msgs = ((InternalEObject)first).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.COLLECTION_RANGE__FIRST, null, msgs); |
| 109 | if (newFirst != null) |
| 110 | msgs = ((InternalEObject)newFirst).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.COLLECTION_RANGE__FIRST, null, msgs); |
| 111 | msgs = basicSetFirst(newFirst, msgs); |
| 112 | if (msgs != null) msgs.dispatch(); |
| 113 | } |
| 114 | else if (eNotificationRequired()) |
| 115 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.COLLECTION_RANGE__FIRST, newFirst, newFirst)); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * <!-- begin-user-doc --> |
| 120 | * <!-- end-user-doc --> |
| 121 | * @generated |
| 122 | */ |
| 123 | public OclExpression getLast() { |
| 124 | return last; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * <!-- begin-user-doc --> |
| 129 | * <!-- end-user-doc --> |
| 130 | * @generated |
| 131 | */ |
| 132 | public NotificationChain basicSetLast(OclExpression newLast, NotificationChain msgs) { |
| 133 | OclExpression oldLast = last; |
| 134 | last = newLast; |
| 135 | if (eNotificationRequired()) { |
| 136 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.COLLECTION_RANGE__LAST, oldLast, newLast); |
| 137 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 138 | } |
| 139 | return msgs; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * <!-- begin-user-doc --> |
| 144 | * <!-- end-user-doc --> |
| 145 | * @generated |
| 146 | */ |
| 147 | public void setLast(OclExpression newLast) { |
| 148 | if (newLast != last) { |
| 149 | NotificationChain msgs = null; |
| 150 | if (last != null) |
| 151 | msgs = ((InternalEObject)last).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.COLLECTION_RANGE__LAST, null, msgs); |
| 152 | if (newLast != null) |
| 153 | msgs = ((InternalEObject)newLast).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.COLLECTION_RANGE__LAST, null, msgs); |
| 154 | msgs = basicSetLast(newLast, msgs); |
| 155 | if (msgs != null) msgs.dispatch(); |
| 156 | } |
| 157 | else if (eNotificationRequired()) |
| 158 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.COLLECTION_RANGE__LAST, newLast, newLast)); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * <!-- begin-user-doc --> |
| 163 | * <!-- end-user-doc --> |
| 164 | * @generated |
| 165 | */ |
| 166 | @Override |
| 167 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 168 | switch (featureID) { |
| 169 | case EssentialOCLPackage.COLLECTION_RANGE__FIRST: |
| 170 | return basicSetFirst(null, msgs); |
| 171 | case EssentialOCLPackage.COLLECTION_RANGE__LAST: |
| 172 | return basicSetLast(null, msgs); |
| 173 | } |
| 174 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * <!-- begin-user-doc --> |
| 179 | * <!-- end-user-doc --> |
| 180 | * @generated |
| 181 | */ |
| 182 | @Override |
| 183 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 184 | switch (featureID) { |
| 185 | case EssentialOCLPackage.COLLECTION_RANGE__FIRST: |
| 186 | return getFirst(); |
| 187 | case EssentialOCLPackage.COLLECTION_RANGE__LAST: |
| 188 | return getLast(); |
| 189 | } |
| 190 | return super.eGet(featureID, resolve, coreType); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * <!-- begin-user-doc --> |
| 195 | * <!-- end-user-doc --> |
| 196 | * @generated |
| 197 | */ |
| 198 | @Override |
| 199 | public void eSet(int featureID, Object newValue) { |
| 200 | switch (featureID) { |
| 201 | case EssentialOCLPackage.COLLECTION_RANGE__FIRST: |
| 202 | setFirst((OclExpression)newValue); |
| 203 | return; |
| 204 | case EssentialOCLPackage.COLLECTION_RANGE__LAST: |
| 205 | setLast((OclExpression)newValue); |
| 206 | return; |
| 207 | } |
| 208 | super.eSet(featureID, newValue); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * <!-- begin-user-doc --> |
| 213 | * <!-- end-user-doc --> |
| 214 | * @generated |
| 215 | */ |
| 216 | @Override |
| 217 | public void eUnset(int featureID) { |
| 218 | switch (featureID) { |
| 219 | case EssentialOCLPackage.COLLECTION_RANGE__FIRST: |
| 220 | setFirst((OclExpression)null); |
| 221 | return; |
| 222 | case EssentialOCLPackage.COLLECTION_RANGE__LAST: |
| 223 | setLast((OclExpression)null); |
| 224 | return; |
| 225 | } |
| 226 | super.eUnset(featureID); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * <!-- begin-user-doc --> |
| 231 | * <!-- end-user-doc --> |
| 232 | * @generated |
| 233 | */ |
| 234 | @Override |
| 235 | public boolean eIsSet(int featureID) { |
| 236 | switch (featureID) { |
| 237 | case EssentialOCLPackage.COLLECTION_RANGE__FIRST: |
| 238 | return first != null; |
| 239 | case EssentialOCLPackage.COLLECTION_RANGE__LAST: |
| 240 | return last != null; |
| 241 | } |
| 242 | return super.eIsSet(featureID); |
| 243 | } |
| 244 | |
| 245 | } //CollectionRangeImpl |