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