| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl; |
| 8 | |
| 9 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.Frequency; |
| 10 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractPackage; |
| 11 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.RangeValue; |
| 12 | |
| 13 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.util.QMLContractValidator; |
| 14 | |
| 15 | import java.util.Map; |
| 16 | |
| 17 | import org.eclipse.emf.common.notify.Notification; |
| 18 | import org.eclipse.emf.common.notify.NotificationChain; |
| 19 | |
| 20 | import org.eclipse.emf.common.util.BasicDiagnostic; |
| 21 | import org.eclipse.emf.common.util.Diagnostic; |
| 22 | import org.eclipse.emf.common.util.DiagnosticChain; |
| 23 | |
| 24 | import org.eclipse.emf.ecore.EClass; |
| 25 | import org.eclipse.emf.ecore.InternalEObject; |
| 26 | |
| 27 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 28 | |
| 29 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 30 | |
| 31 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 32 | |
| 33 | import org.eclipse.ocl.ParserException; |
| 34 | |
| 35 | import org.eclipse.ocl.ecore.Constraint; |
| 36 | import org.eclipse.ocl.ecore.OCL; |
| 37 | |
| 38 | /** |
| 39 | * <!-- begin-user-doc --> |
| 40 | * An implementation of the model object '<em><b>Frequency</b></em>'. |
| 41 | * <!-- end-user-doc --> |
| 42 | * <p> |
| 43 | * The following features are implemented: |
| 44 | * <ul> |
| 45 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl.FrequencyImpl#getUpperLimit <em>Upper Limit</em>}</li> |
| 46 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl.FrequencyImpl#getLowerLimit <em>Lower Limit</em>}</li> |
| 47 | * </ul> |
| 48 | * </p> |
| 49 | * |
| 50 | * @generated |
| 51 | */ |
| 52 | public class FrequencyImpl extends StochasticEvaluationAspectImpl implements Frequency { |
| 53 | /** |
| 54 | * The cached value of the '{@link #getUpperLimit() <em>Upper Limit</em>}' containment reference. |
| 55 | * <!-- begin-user-doc --> |
| 56 | * <!-- end-user-doc --> |
| 57 | * @see #getUpperLimit() |
| 58 | * @generated |
| 59 | * @ordered |
| 60 | */ |
| 61 | protected RangeValue upperLimit; |
| 62 | |
| 63 | /** |
| 64 | * The cached value of the '{@link #getLowerLimit() <em>Lower Limit</em>}' containment reference. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @see #getLowerLimit() |
| 68 | * @generated |
| 69 | * @ordered |
| 70 | */ |
| 71 | protected RangeValue lowerLimit; |
| 72 | |
| 73 | /** |
| 74 | * <!-- begin-user-doc --> |
| 75 | * <!-- end-user-doc --> |
| 76 | * @generated |
| 77 | */ |
| 78 | protected FrequencyImpl() { |
| 79 | super(); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * <!-- begin-user-doc --> |
| 84 | * <!-- end-user-doc --> |
| 85 | * @generated |
| 86 | */ |
| 87 | @Override |
| 88 | protected EClass eStaticClass() { |
| 89 | return QMLContractPackage.Literals.FREQUENCY; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | public RangeValue getUpperLimit() { |
| 98 | return upperLimit; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * <!-- begin-user-doc --> |
| 103 | * <!-- end-user-doc --> |
| 104 | * @generated |
| 105 | */ |
| 106 | public NotificationChain basicSetUpperLimit(RangeValue newUpperLimit, NotificationChain msgs) { |
| 107 | RangeValue oldUpperLimit = upperLimit; |
| 108 | upperLimit = newUpperLimit; |
| 109 | if (eNotificationRequired()) { |
| 110 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QMLContractPackage.FREQUENCY__UPPER_LIMIT, oldUpperLimit, newUpperLimit); |
| 111 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 112 | } |
| 113 | return msgs; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | public void setUpperLimit(RangeValue newUpperLimit) { |
| 122 | if (newUpperLimit != upperLimit) { |
| 123 | NotificationChain msgs = null; |
| 124 | if (upperLimit != null) |
| 125 | msgs = ((InternalEObject)upperLimit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QMLContractPackage.FREQUENCY__UPPER_LIMIT, null, msgs); |
| 126 | if (newUpperLimit != null) |
| 127 | msgs = ((InternalEObject)newUpperLimit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QMLContractPackage.FREQUENCY__UPPER_LIMIT, null, msgs); |
| 128 | msgs = basicSetUpperLimit(newUpperLimit, msgs); |
| 129 | if (msgs != null) msgs.dispatch(); |
| 130 | } |
| 131 | else if (eNotificationRequired()) |
| 132 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractPackage.FREQUENCY__UPPER_LIMIT, newUpperLimit, newUpperLimit)); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * <!-- begin-user-doc --> |
| 137 | * <!-- end-user-doc --> |
| 138 | * @generated |
| 139 | */ |
| 140 | public RangeValue getLowerLimit() { |
| 141 | return lowerLimit; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * <!-- begin-user-doc --> |
| 146 | * <!-- end-user-doc --> |
| 147 | * @generated |
| 148 | */ |
| 149 | public NotificationChain basicSetLowerLimit(RangeValue newLowerLimit, NotificationChain msgs) { |
| 150 | RangeValue oldLowerLimit = lowerLimit; |
| 151 | lowerLimit = newLowerLimit; |
| 152 | if (eNotificationRequired()) { |
| 153 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QMLContractPackage.FREQUENCY__LOWER_LIMIT, oldLowerLimit, newLowerLimit); |
| 154 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 155 | } |
| 156 | return msgs; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * <!-- begin-user-doc --> |
| 161 | * <!-- end-user-doc --> |
| 162 | * @generated |
| 163 | */ |
| 164 | public void setLowerLimit(RangeValue newLowerLimit) { |
| 165 | if (newLowerLimit != lowerLimit) { |
| 166 | NotificationChain msgs = null; |
| 167 | if (lowerLimit != null) |
| 168 | msgs = ((InternalEObject)lowerLimit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QMLContractPackage.FREQUENCY__LOWER_LIMIT, null, msgs); |
| 169 | if (newLowerLimit != null) |
| 170 | msgs = ((InternalEObject)newLowerLimit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QMLContractPackage.FREQUENCY__LOWER_LIMIT, null, msgs); |
| 171 | msgs = basicSetLowerLimit(newLowerLimit, msgs); |
| 172 | if (msgs != null) msgs.dispatch(); |
| 173 | } |
| 174 | else if (eNotificationRequired()) |
| 175 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractPackage.FREQUENCY__LOWER_LIMIT, newLowerLimit, newLowerLimit)); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * The cached OCL expression body for the '{@link #range_of_FREQUENCY_must_have_UPPERLIMIT_or_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Range of FREQUENCY must have UPPERLIMIT or LOWERLIMIT</em>}' operation. |
| 180 | * <!-- begin-user-doc --> |
| 181 | * <!-- end-user-doc --> |
| 182 | * @see #range_of_FREQUENCY_must_have_UPPERLIMIT_or_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 183 | * @generated |
| 184 | * @ordered |
| 185 | */ |
| 186 | protected static final String RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "(self.lowerLimit <> null) or (self.upperLimit <> null)"; |
| 187 | |
| 188 | /** |
| 189 | * The cached OCL invariant for the '{@link #range_of_FREQUENCY_must_have_UPPERLIMIT_or_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Range of FREQUENCY must have UPPERLIMIT or LOWERLIMIT</em>}' invariant operation. |
| 190 | * <!-- begin-user-doc --> |
| 191 | * <!-- end-user-doc --> |
| 192 | * @see #range_of_FREQUENCY_must_have_UPPERLIMIT_or_LOWERLIMIT(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 193 | * @generated |
| 194 | * @ordered |
| 195 | */ |
| 196 | protected static Constraint RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 197 | |
| 198 | /** |
| 199 | * <!-- begin-user-doc --> |
| 200 | * <!-- end-user-doc --> |
| 201 | * @generated |
| 202 | */ |
| 203 | public boolean range_of_FREQUENCY_must_have_UPPERLIMIT_or_LOWERLIMIT(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 204 | if (RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 205 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 206 | helper.setContext(QMLContractPackage.Literals.FREQUENCY); |
| 207 | try { |
| 208 | RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 209 | } |
| 210 | catch (ParserException pe) { |
| 211 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 212 | } |
| 213 | } |
| 214 | if (!EOCL_ENV.createQuery(RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 215 | if (diagnostics != null) { |
| 216 | diagnostics.add |
| 217 | (new BasicDiagnostic |
| 218 | (Diagnostic.ERROR, |
| 219 | QMLContractValidator.DIAGNOSTIC_SOURCE, |
| 220 | QMLContractValidator.FREQUENCY__RANGE_OF_FREQUENCY_MUST_HAVE_UPPERLIMIT_OR_LOWERLIMIT, |
| 221 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "range_of_FREQUENCY_must_have_UPPERLIMIT_or_LOWERLIMIT", EObjectValidator.getObjectLabel(this, context) }), |
| 222 | new Object [] { this })); |
| 223 | } |
| 224 | return false; |
| 225 | } |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * <!-- begin-user-doc --> |
| 231 | * <!-- end-user-doc --> |
| 232 | * @generated |
| 233 | */ |
| 234 | @Override |
| 235 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 236 | switch (featureID) { |
| 237 | case QMLContractPackage.FREQUENCY__UPPER_LIMIT: |
| 238 | return basicSetUpperLimit(null, msgs); |
| 239 | case QMLContractPackage.FREQUENCY__LOWER_LIMIT: |
| 240 | return basicSetLowerLimit(null, msgs); |
| 241 | } |
| 242 | return super.eInverseRemove(otherEnd, featureID, 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 QMLContractPackage.FREQUENCY__UPPER_LIMIT: |
| 254 | return getUpperLimit(); |
| 255 | case QMLContractPackage.FREQUENCY__LOWER_LIMIT: |
| 256 | return getLowerLimit(); |
| 257 | } |
| 258 | return super.eGet(featureID, resolve, coreType); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * <!-- begin-user-doc --> |
| 263 | * <!-- end-user-doc --> |
| 264 | * @generated |
| 265 | */ |
| 266 | @Override |
| 267 | public void eSet(int featureID, Object newValue) { |
| 268 | switch (featureID) { |
| 269 | case QMLContractPackage.FREQUENCY__UPPER_LIMIT: |
| 270 | setUpperLimit((RangeValue)newValue); |
| 271 | return; |
| 272 | case QMLContractPackage.FREQUENCY__LOWER_LIMIT: |
| 273 | setLowerLimit((RangeValue)newValue); |
| 274 | return; |
| 275 | } |
| 276 | super.eSet(featureID, newValue); |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * <!-- begin-user-doc --> |
| 281 | * <!-- end-user-doc --> |
| 282 | * @generated |
| 283 | */ |
| 284 | @Override |
| 285 | public void eUnset(int featureID) { |
| 286 | switch (featureID) { |
| 287 | case QMLContractPackage.FREQUENCY__UPPER_LIMIT: |
| 288 | setUpperLimit((RangeValue)null); |
| 289 | return; |
| 290 | case QMLContractPackage.FREQUENCY__LOWER_LIMIT: |
| 291 | setLowerLimit((RangeValue)null); |
| 292 | return; |
| 293 | } |
| 294 | super.eUnset(featureID); |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * <!-- begin-user-doc --> |
| 299 | * <!-- end-user-doc --> |
| 300 | * @generated |
| 301 | */ |
| 302 | @Override |
| 303 | public boolean eIsSet(int featureID) { |
| 304 | switch (featureID) { |
| 305 | case QMLContractPackage.FREQUENCY__UPPER_LIMIT: |
| 306 | return upperLimit != null; |
| 307 | case QMLContractPackage.FREQUENCY__LOWER_LIMIT: |
| 308 | return lowerLimit != null; |
| 309 | } |
| 310 | return super.eIsSet(featureID); |
| 311 | } |
| 312 | |
| 313 | } //FrequencyImpl |