| 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.*; |
| 10 | |
| 11 | import org.eclipse.emf.ecore.EClass; |
| 12 | import org.eclipse.emf.ecore.EDataType; |
| 13 | import org.eclipse.emf.ecore.EObject; |
| 14 | import org.eclipse.emf.ecore.EPackage; |
| 15 | |
| 16 | import org.eclipse.emf.ecore.impl.EFactoryImpl; |
| 17 | |
| 18 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 19 | |
| 20 | /** |
| 21 | * <!-- begin-user-doc --> |
| 22 | * An implementation of the model <b>Factory</b>. |
| 23 | * <!-- end-user-doc --> |
| 24 | * @generated |
| 25 | */ |
| 26 | public class QMLContractFactoryImpl extends EFactoryImpl implements QMLContractFactory { |
| 27 | /** |
| 28 | * Creates the default factory implementation. |
| 29 | * <!-- begin-user-doc --> |
| 30 | * <!-- end-user-doc --> |
| 31 | * @generated |
| 32 | */ |
| 33 | public static QMLContractFactory init() { |
| 34 | try { |
| 35 | QMLContractFactory theQMLContractFactory = (QMLContractFactory)EPackage.Registry.INSTANCE.getEFactory("http:///QMLContract.ecore"); |
| 36 | if (theQMLContractFactory != null) { |
| 37 | return theQMLContractFactory; |
| 38 | } |
| 39 | } |
| 40 | catch (Exception exception) { |
| 41 | EcorePlugin.INSTANCE.log(exception); |
| 42 | } |
| 43 | return new QMLContractFactoryImpl(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Creates an instance of the factory. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @generated |
| 51 | */ |
| 52 | public QMLContractFactoryImpl() { |
| 53 | super(); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * <!-- begin-user-doc --> |
| 58 | * <!-- end-user-doc --> |
| 59 | * @generated |
| 60 | */ |
| 61 | @Override |
| 62 | public EObject create(EClass eClass) { |
| 63 | switch (eClass.getClassifierID()) { |
| 64 | case QMLContractPackage.SIMPLE_QML_CONTRACT: return createSimpleQMLContract(); |
| 65 | case QMLContractPackage.PERCENTILE: return createPercentile(); |
| 66 | case QMLContractPackage.FREQUENCY: return createFrequency(); |
| 67 | case QMLContractPackage.RANGE_VALUE: return createRangeValue(); |
| 68 | case QMLContractPackage.MEAN: return createMean(); |
| 69 | case QMLContractPackage.VARIANCE: return createVariance(); |
| 70 | case QMLContractPackage.NUMERIC_LITERAL: return createNumericLiteral(); |
| 71 | case QMLContractPackage.ENUM_LITERAL: return createEnumLiteral(); |
| 72 | case QMLContractPackage.SET_LITERAL: return createSetLiteral(); |
| 73 | case QMLContractPackage.REFINED_QML_CONTRACT: return createRefinedQMLContract(); |
| 74 | case QMLContractPackage.VALUE: return createValue(); |
| 75 | case QMLContractPackage.OBJECTIVE: return createObjective(); |
| 76 | case QMLContractPackage.CONSTRAINT: return createConstraint(); |
| 77 | case QMLContractPackage.RESTRICTION: return createRestriction(); |
| 78 | case QMLContractPackage.GOAL: return createGoal(); |
| 79 | default: |
| 80 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * <!-- begin-user-doc --> |
| 86 | * <!-- end-user-doc --> |
| 87 | * @generated |
| 88 | */ |
| 89 | @Override |
| 90 | public Object createFromString(EDataType eDataType, String initialValue) { |
| 91 | switch (eDataType.getClassifierID()) { |
| 92 | case QMLContractPackage.ENUM_OPERATOR: |
| 93 | return createEnumOperatorFromString(eDataType, initialValue); |
| 94 | case QMLContractPackage.ENUM_RANGE_VALUE_TYPE: |
| 95 | return createEnumRangeValueTypeFromString(eDataType, initialValue); |
| 96 | default: |
| 97 | throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * <!-- begin-user-doc --> |
| 103 | * <!-- end-user-doc --> |
| 104 | * @generated |
| 105 | */ |
| 106 | @Override |
| 107 | public String convertToString(EDataType eDataType, Object instanceValue) { |
| 108 | switch (eDataType.getClassifierID()) { |
| 109 | case QMLContractPackage.ENUM_OPERATOR: |
| 110 | return convertEnumOperatorToString(eDataType, instanceValue); |
| 111 | case QMLContractPackage.ENUM_RANGE_VALUE_TYPE: |
| 112 | return convertEnumRangeValueTypeToString(eDataType, instanceValue); |
| 113 | default: |
| 114 | throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * <!-- begin-user-doc --> |
| 120 | * <!-- end-user-doc --> |
| 121 | * @generated |
| 122 | */ |
| 123 | public SimpleQMLContract createSimpleQMLContract() { |
| 124 | SimpleQMLContractImpl simpleQMLContract = new SimpleQMLContractImpl(); |
| 125 | return simpleQMLContract; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * <!-- begin-user-doc --> |
| 130 | * <!-- end-user-doc --> |
| 131 | * @generated |
| 132 | */ |
| 133 | public Percentile createPercentile() { |
| 134 | PercentileImpl percentile = new PercentileImpl(); |
| 135 | return percentile; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * <!-- begin-user-doc --> |
| 140 | * <!-- end-user-doc --> |
| 141 | * @generated |
| 142 | */ |
| 143 | public Frequency createFrequency() { |
| 144 | FrequencyImpl frequency = new FrequencyImpl(); |
| 145 | return frequency; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * <!-- begin-user-doc --> |
| 150 | * <!-- end-user-doc --> |
| 151 | * @generated |
| 152 | */ |
| 153 | public RangeValue createRangeValue() { |
| 154 | RangeValueImpl rangeValue = new RangeValueImpl(); |
| 155 | return rangeValue; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * <!-- begin-user-doc --> |
| 160 | * <!-- end-user-doc --> |
| 161 | * @generated |
| 162 | */ |
| 163 | public Mean createMean() { |
| 164 | MeanImpl mean = new MeanImpl(); |
| 165 | return mean; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * <!-- begin-user-doc --> |
| 170 | * <!-- end-user-doc --> |
| 171 | * @generated |
| 172 | */ |
| 173 | public Variance createVariance() { |
| 174 | VarianceImpl variance = new VarianceImpl(); |
| 175 | return variance; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * <!-- begin-user-doc --> |
| 180 | * <!-- end-user-doc --> |
| 181 | * @generated |
| 182 | */ |
| 183 | public NumericLiteral createNumericLiteral() { |
| 184 | NumericLiteralImpl numericLiteral = new NumericLiteralImpl(); |
| 185 | return numericLiteral; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * <!-- begin-user-doc --> |
| 190 | * <!-- end-user-doc --> |
| 191 | * @generated |
| 192 | */ |
| 193 | public EnumLiteral createEnumLiteral() { |
| 194 | EnumLiteralImpl enumLiteral = new EnumLiteralImpl(); |
| 195 | return enumLiteral; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * <!-- begin-user-doc --> |
| 200 | * <!-- end-user-doc --> |
| 201 | * @generated |
| 202 | */ |
| 203 | public SetLiteral createSetLiteral() { |
| 204 | SetLiteralImpl setLiteral = new SetLiteralImpl(); |
| 205 | return setLiteral; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * <!-- begin-user-doc --> |
| 210 | * <!-- end-user-doc --> |
| 211 | * @generated |
| 212 | */ |
| 213 | public RefinedQMLContract createRefinedQMLContract() { |
| 214 | RefinedQMLContractImpl refinedQMLContract = new RefinedQMLContractImpl(); |
| 215 | return refinedQMLContract; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * <!-- begin-user-doc --> |
| 220 | * <!-- end-user-doc --> |
| 221 | * @generated |
| 222 | */ |
| 223 | public Value createValue() { |
| 224 | ValueImpl value = new ValueImpl(); |
| 225 | return value; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * <!-- begin-user-doc --> |
| 230 | * <!-- end-user-doc --> |
| 231 | * @generated |
| 232 | */ |
| 233 | public Objective createObjective() { |
| 234 | ObjectiveImpl objective = new ObjectiveImpl(); |
| 235 | return objective; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * <!-- begin-user-doc --> |
| 240 | * <!-- end-user-doc --> |
| 241 | * @generated |
| 242 | */ |
| 243 | public Constraint createConstraint() { |
| 244 | ConstraintImpl constraint = new ConstraintImpl(); |
| 245 | return constraint; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * <!-- begin-user-doc --> |
| 250 | * <!-- end-user-doc --> |
| 251 | * @generated |
| 252 | */ |
| 253 | public Restriction createRestriction() { |
| 254 | RestrictionImpl restriction = new RestrictionImpl(); |
| 255 | return restriction; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * <!-- begin-user-doc --> |
| 260 | * <!-- end-user-doc --> |
| 261 | * @generated |
| 262 | */ |
| 263 | public Goal createGoal() { |
| 264 | GoalImpl goal = new GoalImpl(); |
| 265 | return goal; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * <!-- begin-user-doc --> |
| 270 | * <!-- end-user-doc --> |
| 271 | * @generated |
| 272 | */ |
| 273 | public EnumOperator createEnumOperatorFromString(EDataType eDataType, String initialValue) { |
| 274 | EnumOperator result = EnumOperator.get(initialValue); |
| 275 | if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); |
| 276 | return result; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * <!-- begin-user-doc --> |
| 281 | * <!-- end-user-doc --> |
| 282 | * @generated |
| 283 | */ |
| 284 | public String convertEnumOperatorToString(EDataType eDataType, Object instanceValue) { |
| 285 | return instanceValue == null ? null : instanceValue.toString(); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * <!-- begin-user-doc --> |
| 290 | * <!-- end-user-doc --> |
| 291 | * @generated |
| 292 | */ |
| 293 | public EnumRangeValueType createEnumRangeValueTypeFromString(EDataType eDataType, String initialValue) { |
| 294 | EnumRangeValueType result = EnumRangeValueType.get(initialValue); |
| 295 | if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); |
| 296 | return result; |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * <!-- begin-user-doc --> |
| 301 | * <!-- end-user-doc --> |
| 302 | * @generated |
| 303 | */ |
| 304 | public String convertEnumRangeValueTypeToString(EDataType eDataType, Object instanceValue) { |
| 305 | return instanceValue == null ? null : instanceValue.toString(); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * <!-- begin-user-doc --> |
| 310 | * <!-- end-user-doc --> |
| 311 | * @generated |
| 312 | */ |
| 313 | public QMLContractPackage getQMLContractPackage() { |
| 314 | return (QMLContractPackage)getEPackage(); |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * <!-- begin-user-doc --> |
| 319 | * <!-- end-user-doc --> |
| 320 | * @deprecated |
| 321 | * @generated |
| 322 | */ |
| 323 | @Deprecated |
| 324 | public static QMLContractPackage getPackage() { |
| 325 | return QMLContractPackage.eINSTANCE; |
| 326 | } |
| 327 | |
| 328 | } //QMLContractFactoryImpl |