1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.parameter.impl; |
7 | |
8 | import de.uka.ipd.sdq.pcm.parameter.*; |
9 | import org.eclipse.emf.ecore.EClass; |
10 | import org.eclipse.emf.ecore.EDataType; |
11 | import org.eclipse.emf.ecore.EObject; |
12 | import org.eclipse.emf.ecore.EPackage; |
13 | import org.eclipse.emf.ecore.impl.EFactoryImpl; |
14 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
15 | |
16 | import de.uka.ipd.sdq.pcm.parameter.CharacterisedVariable; |
17 | import de.uka.ipd.sdq.pcm.parameter.ParameterFactory; |
18 | import de.uka.ipd.sdq.pcm.parameter.ParameterPackage; |
19 | import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisation; |
20 | import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisationType; |
21 | import de.uka.ipd.sdq.pcm.parameter.VariableUsage; |
22 | |
23 | /** |
24 | * <!-- begin-user-doc --> |
25 | * An implementation of the model <b>Factory</b>. |
26 | * <!-- end-user-doc --> |
27 | * @generated |
28 | */ |
29 | public class ParameterFactoryImpl extends EFactoryImpl implements ParameterFactory { |
30 | /** |
31 | * <!-- begin-user-doc --> |
32 | * <!-- end-user-doc --> |
33 | * @generated |
34 | */ |
35 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
36 | |
37 | /** |
38 | * Creates the default factory implementation. |
39 | * <!-- begin-user-doc --> |
40 | * <!-- end-user-doc --> |
41 | * @generated |
42 | */ |
43 | public static ParameterFactory init() { |
44 | try { |
45 | ParameterFactory theParameterFactory = (ParameterFactory)EPackage.Registry.INSTANCE.getEFactory("http://sdq.ipd.uka.de/PalladioComponentModel/Parameter/4.0"); |
46 | if (theParameterFactory != null) { |
47 | return theParameterFactory; |
48 | } |
49 | } |
50 | catch (Exception exception) { |
51 | EcorePlugin.INSTANCE.log(exception); |
52 | } |
53 | return new ParameterFactoryImpl(); |
54 | } |
55 | |
56 | /** |
57 | * Creates an instance of the factory. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @generated |
61 | */ |
62 | public ParameterFactoryImpl() { |
63 | super(); |
64 | } |
65 | |
66 | /** |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @generated |
70 | */ |
71 | @Override |
72 | public EObject create(EClass eClass) { |
73 | switch (eClass.getClassifierID()) { |
74 | case ParameterPackage.VARIABLE_USAGE: return createVariableUsage(); |
75 | case ParameterPackage.VARIABLE_CHARACTERISATION: return createVariableCharacterisation(); |
76 | case ParameterPackage.CHARACTERISED_VARIABLE: return createCharacterisedVariable(); |
77 | default: |
78 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); |
79 | } |
80 | } |
81 | |
82 | /** |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @generated |
86 | */ |
87 | @Override |
88 | public Object createFromString(EDataType eDataType, String initialValue) { |
89 | switch (eDataType.getClassifierID()) { |
90 | case ParameterPackage.VARIABLE_CHARACTERISATION_TYPE: |
91 | return createVariableCharacterisationTypeFromString(eDataType, initialValue); |
92 | default: |
93 | throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
94 | } |
95 | } |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | @Override |
103 | public String convertToString(EDataType eDataType, Object instanceValue) { |
104 | switch (eDataType.getClassifierID()) { |
105 | case ParameterPackage.VARIABLE_CHARACTERISATION_TYPE: |
106 | return convertVariableCharacterisationTypeToString(eDataType, instanceValue); |
107 | default: |
108 | throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
109 | } |
110 | } |
111 | |
112 | /** |
113 | * <!-- begin-user-doc --> |
114 | * <!-- end-user-doc --> |
115 | * @generated |
116 | */ |
117 | public VariableCharacterisation createVariableCharacterisation() { |
118 | VariableCharacterisationImpl variableCharacterisation = new VariableCharacterisationImpl(); |
119 | return variableCharacterisation; |
120 | } |
121 | |
122 | /** |
123 | * <!-- begin-user-doc --> |
124 | * <!-- end-user-doc --> |
125 | * @generated |
126 | */ |
127 | public CharacterisedVariable createCharacterisedVariable() { |
128 | CharacterisedVariableImpl characterisedVariable = new CharacterisedVariableImpl(); |
129 | return characterisedVariable; |
130 | } |
131 | |
132 | /** |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | public VariableUsage createVariableUsage() { |
138 | VariableUsageImpl variableUsage = new VariableUsageImpl(); |
139 | return variableUsage; |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | public VariableCharacterisationType createVariableCharacterisationTypeFromString(EDataType eDataType, String initialValue) { |
148 | VariableCharacterisationType result = VariableCharacterisationType.get(initialValue); |
149 | if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); |
150 | return result; |
151 | } |
152 | |
153 | /** |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | public String convertVariableCharacterisationTypeToString(EDataType eDataType, Object instanceValue) { |
159 | return instanceValue == null ? null : instanceValue.toString(); |
160 | } |
161 | |
162 | /** |
163 | * <!-- begin-user-doc --> |
164 | * <!-- end-user-doc --> |
165 | * @generated |
166 | */ |
167 | public ParameterPackage getParameterPackage() { |
168 | return (ParameterPackage)getEPackage(); |
169 | } |
170 | |
171 | /** |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @deprecated |
175 | * @generated |
176 | */ |
177 | @Deprecated |
178 | public static ParameterPackage getPackage() { |
179 | return ParameterPackage.eINSTANCE; |
180 | } |
181 | |
182 | } //ParameterFactoryImpl |