| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.stoex.impl; |
| 8 | |
| 9 | import org.eclipse.emf.common.notify.Notification; |
| 10 | import org.eclipse.emf.common.notify.NotificationChain; |
| 11 | import org.eclipse.emf.ecore.EClass; |
| 12 | import org.eclipse.emf.ecore.InternalEObject; |
| 13 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 14 | |
| 15 | import de.uka.ipd.sdq.stoex.CompareExpression; |
| 16 | import de.uka.ipd.sdq.stoex.CompareOperations; |
| 17 | import de.uka.ipd.sdq.stoex.StoexPackage; |
| 18 | import de.uka.ipd.sdq.stoex.Term; |
| 19 | |
| 20 | /** |
| 21 | * <!-- begin-user-doc --> |
| 22 | * An implementation of the model object '<em><b>Compare Expression</b></em>'. |
| 23 | * <!-- end-user-doc --> |
| 24 | * <p> |
| 25 | * The following features are implemented: |
| 26 | * <ul> |
| 27 | * <li>{@link de.uka.ipd.sdq.stoex.impl.CompareExpressionImpl#getLeft <em>Left</em>}</li> |
| 28 | * <li>{@link de.uka.ipd.sdq.stoex.impl.CompareExpressionImpl#getRight <em>Right</em>}</li> |
| 29 | * <li>{@link de.uka.ipd.sdq.stoex.impl.CompareExpressionImpl#getOperation <em>Operation</em>}</li> |
| 30 | * </ul> |
| 31 | * </p> |
| 32 | * |
| 33 | * @generated |
| 34 | */ |
| 35 | public class CompareExpressionImpl extends ComparisonImpl implements CompareExpression { |
| 36 | /** |
| 37 | * <!-- begin-user-doc --> |
| 38 | * <!-- end-user-doc --> |
| 39 | * @generated |
| 40 | */ |
| 41 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 42 | |
| 43 | /** |
| 44 | * The cached value of the '{@link #getLeft() <em>Left</em>}' containment reference. |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @see #getLeft() |
| 48 | * @generated |
| 49 | * @ordered |
| 50 | */ |
| 51 | protected Term left; |
| 52 | |
| 53 | /** |
| 54 | * The cached value of the '{@link #getRight() <em>Right</em>}' containment reference. |
| 55 | * <!-- begin-user-doc --> |
| 56 | * <!-- end-user-doc --> |
| 57 | * @see #getRight() |
| 58 | * @generated |
| 59 | * @ordered |
| 60 | */ |
| 61 | protected Term right; |
| 62 | |
| 63 | /** |
| 64 | * The default value of the '{@link #getOperation() <em>Operation</em>}' attribute. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @see #getOperation() |
| 68 | * @generated |
| 69 | * @ordered |
| 70 | */ |
| 71 | protected static final CompareOperations OPERATION_EDEFAULT = CompareOperations.GREATER; |
| 72 | |
| 73 | /** |
| 74 | * The cached value of the '{@link #getOperation() <em>Operation</em>}' attribute. |
| 75 | * <!-- begin-user-doc --> |
| 76 | * <!-- end-user-doc --> |
| 77 | * @see #getOperation() |
| 78 | * @generated |
| 79 | * @ordered |
| 80 | */ |
| 81 | protected CompareOperations operation = OPERATION_EDEFAULT; |
| 82 | |
| 83 | /** |
| 84 | * <!-- begin-user-doc --> |
| 85 | * <!-- end-user-doc --> |
| 86 | * @generated |
| 87 | */ |
| 88 | protected CompareExpressionImpl() { |
| 89 | super(); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | @Override |
| 98 | protected EClass eStaticClass() { |
| 99 | return StoexPackage.Literals.COMPARE_EXPRESSION; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * <!-- begin-user-doc --> |
| 104 | * <!-- end-user-doc --> |
| 105 | * @generated |
| 106 | */ |
| 107 | public Term getLeft() { |
| 108 | return left; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * <!-- begin-user-doc --> |
| 113 | * <!-- end-user-doc --> |
| 114 | * @generated |
| 115 | */ |
| 116 | public NotificationChain basicSetLeft(Term newLeft, NotificationChain msgs) { |
| 117 | Term oldLeft = left; |
| 118 | left = newLeft; |
| 119 | if (eNotificationRequired()) { |
| 120 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StoexPackage.COMPARE_EXPRESSION__LEFT, oldLeft, newLeft); |
| 121 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 122 | } |
| 123 | return msgs; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | public void setLeft(Term newLeft) { |
| 132 | if (newLeft != left) { |
| 133 | NotificationChain msgs = null; |
| 134 | if (left != null) |
| 135 | msgs = ((InternalEObject)left).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StoexPackage.COMPARE_EXPRESSION__LEFT, null, msgs); |
| 136 | if (newLeft != null) |
| 137 | msgs = ((InternalEObject)newLeft).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StoexPackage.COMPARE_EXPRESSION__LEFT, null, msgs); |
| 138 | msgs = basicSetLeft(newLeft, msgs); |
| 139 | if (msgs != null) msgs.dispatch(); |
| 140 | } |
| 141 | else if (eNotificationRequired()) |
| 142 | eNotify(new ENotificationImpl(this, Notification.SET, StoexPackage.COMPARE_EXPRESSION__LEFT, newLeft, newLeft)); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * <!-- begin-user-doc --> |
| 147 | * <!-- end-user-doc --> |
| 148 | * @generated |
| 149 | */ |
| 150 | public Term getRight() { |
| 151 | return right; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * <!-- begin-user-doc --> |
| 156 | * <!-- end-user-doc --> |
| 157 | * @generated |
| 158 | */ |
| 159 | public NotificationChain basicSetRight(Term newRight, NotificationChain msgs) { |
| 160 | Term oldRight = right; |
| 161 | right = newRight; |
| 162 | if (eNotificationRequired()) { |
| 163 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StoexPackage.COMPARE_EXPRESSION__RIGHT, oldRight, newRight); |
| 164 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 165 | } |
| 166 | return msgs; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * <!-- begin-user-doc --> |
| 171 | * <!-- end-user-doc --> |
| 172 | * @generated |
| 173 | */ |
| 174 | public void setRight(Term newRight) { |
| 175 | if (newRight != right) { |
| 176 | NotificationChain msgs = null; |
| 177 | if (right != null) |
| 178 | msgs = ((InternalEObject)right).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StoexPackage.COMPARE_EXPRESSION__RIGHT, null, msgs); |
| 179 | if (newRight != null) |
| 180 | msgs = ((InternalEObject)newRight).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StoexPackage.COMPARE_EXPRESSION__RIGHT, null, msgs); |
| 181 | msgs = basicSetRight(newRight, msgs); |
| 182 | if (msgs != null) msgs.dispatch(); |
| 183 | } |
| 184 | else if (eNotificationRequired()) |
| 185 | eNotify(new ENotificationImpl(this, Notification.SET, StoexPackage.COMPARE_EXPRESSION__RIGHT, newRight, newRight)); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * <!-- begin-user-doc --> |
| 190 | * <!-- end-user-doc --> |
| 191 | * @generated |
| 192 | */ |
| 193 | public CompareOperations getOperation() { |
| 194 | return operation; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * <!-- begin-user-doc --> |
| 199 | * <!-- end-user-doc --> |
| 200 | * @generated |
| 201 | */ |
| 202 | public void setOperation(CompareOperations newOperation) { |
| 203 | CompareOperations oldOperation = operation; |
| 204 | operation = newOperation == null ? OPERATION_EDEFAULT : newOperation; |
| 205 | if (eNotificationRequired()) |
| 206 | eNotify(new ENotificationImpl(this, Notification.SET, StoexPackage.COMPARE_EXPRESSION__OPERATION, oldOperation, operation)); |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * <!-- begin-user-doc --> |
| 211 | * <!-- end-user-doc --> |
| 212 | * @generated |
| 213 | */ |
| 214 | @Override |
| 215 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 216 | switch (featureID) { |
| 217 | case StoexPackage.COMPARE_EXPRESSION__LEFT: |
| 218 | return basicSetLeft(null, msgs); |
| 219 | case StoexPackage.COMPARE_EXPRESSION__RIGHT: |
| 220 | return basicSetRight(null, msgs); |
| 221 | } |
| 222 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * <!-- begin-user-doc --> |
| 227 | * <!-- end-user-doc --> |
| 228 | * @generated |
| 229 | */ |
| 230 | @Override |
| 231 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 232 | switch (featureID) { |
| 233 | case StoexPackage.COMPARE_EXPRESSION__LEFT: |
| 234 | return getLeft(); |
| 235 | case StoexPackage.COMPARE_EXPRESSION__RIGHT: |
| 236 | return getRight(); |
| 237 | case StoexPackage.COMPARE_EXPRESSION__OPERATION: |
| 238 | return getOperation(); |
| 239 | } |
| 240 | return super.eGet(featureID, resolve, coreType); |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * <!-- begin-user-doc --> |
| 245 | * <!-- end-user-doc --> |
| 246 | * @generated |
| 247 | */ |
| 248 | @Override |
| 249 | public void eSet(int featureID, Object newValue) { |
| 250 | switch (featureID) { |
| 251 | case StoexPackage.COMPARE_EXPRESSION__LEFT: |
| 252 | setLeft((Term)newValue); |
| 253 | return; |
| 254 | case StoexPackage.COMPARE_EXPRESSION__RIGHT: |
| 255 | setRight((Term)newValue); |
| 256 | return; |
| 257 | case StoexPackage.COMPARE_EXPRESSION__OPERATION: |
| 258 | setOperation((CompareOperations)newValue); |
| 259 | return; |
| 260 | } |
| 261 | super.eSet(featureID, newValue); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * <!-- begin-user-doc --> |
| 266 | * <!-- end-user-doc --> |
| 267 | * @generated |
| 268 | */ |
| 269 | @Override |
| 270 | public void eUnset(int featureID) { |
| 271 | switch (featureID) { |
| 272 | case StoexPackage.COMPARE_EXPRESSION__LEFT: |
| 273 | setLeft((Term)null); |
| 274 | return; |
| 275 | case StoexPackage.COMPARE_EXPRESSION__RIGHT: |
| 276 | setRight((Term)null); |
| 277 | return; |
| 278 | case StoexPackage.COMPARE_EXPRESSION__OPERATION: |
| 279 | setOperation(OPERATION_EDEFAULT); |
| 280 | return; |
| 281 | } |
| 282 | super.eUnset(featureID); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * <!-- begin-user-doc --> |
| 287 | * <!-- end-user-doc --> |
| 288 | * @generated |
| 289 | */ |
| 290 | @Override |
| 291 | public boolean eIsSet(int featureID) { |
| 292 | switch (featureID) { |
| 293 | case StoexPackage.COMPARE_EXPRESSION__LEFT: |
| 294 | return left != null; |
| 295 | case StoexPackage.COMPARE_EXPRESSION__RIGHT: |
| 296 | return right != null; |
| 297 | case StoexPackage.COMPARE_EXPRESSION__OPERATION: |
| 298 | return operation != OPERATION_EDEFAULT; |
| 299 | } |
| 300 | return super.eIsSet(featureID); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * <!-- begin-user-doc --> |
| 305 | * <!-- end-user-doc --> |
| 306 | * @generated |
| 307 | */ |
| 308 | @Override |
| 309 | public String toString() { |
| 310 | if (eIsProxy()) return super.toString(); |
| 311 | |
| 312 | StringBuffer result = new StringBuffer(super.toString()); |
| 313 | result.append(" (operation: "); |
| 314 | result.append(operation); |
| 315 | result.append(')'); |
| 316 | return result.toString(); |
| 317 | } |
| 318 | |
| 319 | } //CompareExpressionImpl |