| 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.Percentile; |
| 10 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractPackage; |
| 11 | |
| 12 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.util.QMLContractValidator; |
| 13 | |
| 14 | import java.util.Map; |
| 15 | |
| 16 | import org.eclipse.emf.common.notify.Notification; |
| 17 | |
| 18 | import org.eclipse.emf.common.util.BasicDiagnostic; |
| 19 | import org.eclipse.emf.common.util.Diagnostic; |
| 20 | import org.eclipse.emf.common.util.DiagnosticChain; |
| 21 | |
| 22 | import org.eclipse.emf.ecore.EClass; |
| 23 | |
| 24 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 25 | |
| 26 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 27 | |
| 28 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 29 | |
| 30 | import org.eclipse.ocl.ParserException; |
| 31 | |
| 32 | import org.eclipse.ocl.ecore.Constraint; |
| 33 | import org.eclipse.ocl.ecore.OCL; |
| 34 | |
| 35 | /** |
| 36 | * <!-- begin-user-doc --> |
| 37 | * An implementation of the model object '<em><b>Percentile</b></em>'. |
| 38 | * <!-- end-user-doc --> |
| 39 | * <p> |
| 40 | * The following features are implemented: |
| 41 | * <ul> |
| 42 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl.PercentileImpl#getPercentile <em>Percentile</em>}</li> |
| 43 | * </ul> |
| 44 | * </p> |
| 45 | * |
| 46 | * @generated |
| 47 | */ |
| 48 | public class PercentileImpl extends PointEstimatorImpl implements Percentile { |
| 49 | /** |
| 50 | * The default value of the '{@link #getPercentile() <em>Percentile</em>}' attribute. |
| 51 | * <!-- begin-user-doc --> |
| 52 | * <!-- end-user-doc --> |
| 53 | * @see #getPercentile() |
| 54 | * @generated |
| 55 | * @ordered |
| 56 | */ |
| 57 | protected static final double PERCENTILE_EDEFAULT = 0.0; |
| 58 | |
| 59 | /** |
| 60 | * The cached value of the '{@link #getPercentile() <em>Percentile</em>}' attribute. |
| 61 | * <!-- begin-user-doc --> |
| 62 | * <!-- end-user-doc --> |
| 63 | * @see #getPercentile() |
| 64 | * @generated |
| 65 | * @ordered |
| 66 | */ |
| 67 | protected double percentile = PERCENTILE_EDEFAULT; |
| 68 | |
| 69 | /** |
| 70 | * <!-- begin-user-doc --> |
| 71 | * <!-- end-user-doc --> |
| 72 | * @generated |
| 73 | */ |
| 74 | protected PercentileImpl() { |
| 75 | super(); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | @Override |
| 84 | protected EClass eStaticClass() { |
| 85 | return QMLContractPackage.Literals.PERCENTILE; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * <!-- begin-user-doc --> |
| 90 | * <!-- end-user-doc --> |
| 91 | * @generated |
| 92 | */ |
| 93 | public double getPercentile() { |
| 94 | return percentile; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * <!-- begin-user-doc --> |
| 99 | * <!-- end-user-doc --> |
| 100 | * @generated |
| 101 | */ |
| 102 | public void setPercentile(double newPercentile) { |
| 103 | double oldPercentile = percentile; |
| 104 | percentile = newPercentile; |
| 105 | if (eNotificationRequired()) |
| 106 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractPackage.PERCENTILE__PERCENTILE, oldPercentile, percentile)); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * The cached OCL expression body for the '{@link #PERCENTILE_between_0_and_100(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>PERCENTILE between 0and 100</em>}' operation. |
| 111 | * <!-- begin-user-doc --> |
| 112 | * <!-- end-user-doc --> |
| 113 | * @see #PERCENTILE_between_0_and_100(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 114 | * @generated |
| 115 | * @ordered |
| 116 | */ |
| 117 | protected static final String PERCENTILE_BETWEEN_0AND_100__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.percentile.oclAsType(Real) > 0.0 and self.percentile.oclAsType(Real) < 100.0"; |
| 118 | |
| 119 | /** |
| 120 | * The cached OCL invariant for the '{@link #PERCENTILE_between_0_and_100(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>PERCENTILE between 0and 100</em>}' invariant operation. |
| 121 | * <!-- begin-user-doc --> |
| 122 | * <!-- end-user-doc --> |
| 123 | * @see #PERCENTILE_between_0_and_100(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 124 | * @generated |
| 125 | * @ordered |
| 126 | */ |
| 127 | protected static Constraint PERCENTILE_BETWEEN_0AND_100__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 128 | |
| 129 | /** |
| 130 | * <!-- begin-user-doc --> |
| 131 | * <!-- end-user-doc --> |
| 132 | * @generated |
| 133 | */ |
| 134 | public boolean PERCENTILE_between_0_and_100(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 135 | if (PERCENTILE_BETWEEN_0AND_100__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 136 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 137 | helper.setContext(QMLContractPackage.Literals.PERCENTILE); |
| 138 | try { |
| 139 | PERCENTILE_BETWEEN_0AND_100__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PERCENTILE_BETWEEN_0AND_100__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 140 | } |
| 141 | catch (ParserException pe) { |
| 142 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 143 | } |
| 144 | } |
| 145 | if (!EOCL_ENV.createQuery(PERCENTILE_BETWEEN_0AND_100__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 146 | if (diagnostics != null) { |
| 147 | diagnostics.add |
| 148 | (new BasicDiagnostic |
| 149 | (Diagnostic.ERROR, |
| 150 | QMLContractValidator.DIAGNOSTIC_SOURCE, |
| 151 | QMLContractValidator.PERCENTILE__PERCENTILE_BETWEEN_0AND_100, |
| 152 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "PERCENTILE_between_0_and_100", EObjectValidator.getObjectLabel(this, context) }), |
| 153 | new Object [] { this })); |
| 154 | } |
| 155 | return false; |
| 156 | } |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * <!-- begin-user-doc --> |
| 162 | * <!-- end-user-doc --> |
| 163 | * @generated |
| 164 | */ |
| 165 | @Override |
| 166 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 167 | switch (featureID) { |
| 168 | case QMLContractPackage.PERCENTILE__PERCENTILE: |
| 169 | return getPercentile(); |
| 170 | } |
| 171 | return super.eGet(featureID, resolve, coreType); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * <!-- begin-user-doc --> |
| 176 | * <!-- end-user-doc --> |
| 177 | * @generated |
| 178 | */ |
| 179 | @Override |
| 180 | public void eSet(int featureID, Object newValue) { |
| 181 | switch (featureID) { |
| 182 | case QMLContractPackage.PERCENTILE__PERCENTILE: |
| 183 | setPercentile((Double)newValue); |
| 184 | return; |
| 185 | } |
| 186 | super.eSet(featureID, newValue); |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * <!-- begin-user-doc --> |
| 191 | * <!-- end-user-doc --> |
| 192 | * @generated |
| 193 | */ |
| 194 | @Override |
| 195 | public void eUnset(int featureID) { |
| 196 | switch (featureID) { |
| 197 | case QMLContractPackage.PERCENTILE__PERCENTILE: |
| 198 | setPercentile(PERCENTILE_EDEFAULT); |
| 199 | return; |
| 200 | } |
| 201 | super.eUnset(featureID); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * <!-- begin-user-doc --> |
| 206 | * <!-- end-user-doc --> |
| 207 | * @generated |
| 208 | */ |
| 209 | @Override |
| 210 | public boolean eIsSet(int featureID) { |
| 211 | switch (featureID) { |
| 212 | case QMLContractPackage.PERCENTILE__PERCENTILE: |
| 213 | return percentile != PERCENTILE_EDEFAULT; |
| 214 | } |
| 215 | return super.eIsSet(featureID); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * <!-- begin-user-doc --> |
| 220 | * <!-- end-user-doc --> |
| 221 | * @generated |
| 222 | */ |
| 223 | @Override |
| 224 | public String toString() { |
| 225 | if (eIsProxy()) return super.toString(); |
| 226 | |
| 227 | StringBuffer result = new StringBuffer(super.toString()); |
| 228 | result.append(" (percentile: "); |
| 229 | result.append(percentile); |
| 230 | result.append(')'); |
| 231 | return result.toString(); |
| 232 | } |
| 233 | |
| 234 | } //PercentileImpl |