| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.resourceenvironment.impl; |
| 7 | |
| 8 | import de.uka.ipd.sdq.pcm.resourceenvironment.*; |
| 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.resourceenvironment.CommunicationLinkResourceSpecification; |
| 17 | import de.uka.ipd.sdq.pcm.resourceenvironment.ContainerOperatingSystem; |
| 18 | import de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource; |
| 19 | import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification; |
| 20 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
| 21 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceEnvironment; |
| 22 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentFactory; |
| 23 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
| 24 | import de.uka.ipd.sdq.pcm.resourceenvironment.SchedulingPolicy; |
| 25 | |
| 26 | /** |
| 27 | * <!-- begin-user-doc --> |
| 28 | * An implementation of the model <b>Factory</b>. |
| 29 | * <!-- end-user-doc --> |
| 30 | * @generated |
| 31 | */ |
| 32 | public class ResourceenvironmentFactoryImpl extends EFactoryImpl implements ResourceenvironmentFactory { |
| 33 | /** |
| 34 | * <!-- begin-user-doc --> |
| 35 | * <!-- end-user-doc --> |
| 36 | * @generated |
| 37 | */ |
| 38 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 39 | |
| 40 | /** |
| 41 | * Creates the default factory implementation. |
| 42 | * <!-- begin-user-doc --> |
| 43 | * <!-- end-user-doc --> |
| 44 | * @generated |
| 45 | */ |
| 46 | public static ResourceenvironmentFactory init() { |
| 47 | try { |
| 48 | ResourceenvironmentFactory theResourceenvironmentFactory = (ResourceenvironmentFactory)EPackage.Registry.INSTANCE.getEFactory("http://sdq.ipd.uka.de/PalladioComponentModel/ResourceEnvironment/4.0"); |
| 49 | if (theResourceenvironmentFactory != null) { |
| 50 | return theResourceenvironmentFactory; |
| 51 | } |
| 52 | } |
| 53 | catch (Exception exception) { |
| 54 | EcorePlugin.INSTANCE.log(exception); |
| 55 | } |
| 56 | return new ResourceenvironmentFactoryImpl(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Creates an instance of the factory. |
| 61 | * <!-- begin-user-doc --> |
| 62 | * <!-- end-user-doc --> |
| 63 | * @generated |
| 64 | */ |
| 65 | public ResourceenvironmentFactoryImpl() { |
| 66 | super(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * <!-- begin-user-doc --> |
| 71 | * <!-- end-user-doc --> |
| 72 | * @generated |
| 73 | */ |
| 74 | @Override |
| 75 | public EObject create(EClass eClass) { |
| 76 | switch (eClass.getClassifierID()) { |
| 77 | case ResourceenvironmentPackage.RESOURCE_ENVIRONMENT: return createResourceEnvironment(); |
| 78 | case ResourceenvironmentPackage.LINKING_RESOURCE: return createLinkingResource(); |
| 79 | case ResourceenvironmentPackage.RESOURCE_CONTAINER: return createResourceContainer(); |
| 80 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION: return createProcessingResourceSpecification(); |
| 81 | case ResourceenvironmentPackage.COMMUNICATION_LINK_RESOURCE_SPECIFICATION: return createCommunicationLinkResourceSpecification(); |
| 82 | default: |
| 83 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * <!-- begin-user-doc --> |
| 89 | * <!-- end-user-doc --> |
| 90 | * @generated |
| 91 | */ |
| 92 | @Override |
| 93 | public Object createFromString(EDataType eDataType, String initialValue) { |
| 94 | switch (eDataType.getClassifierID()) { |
| 95 | case ResourceenvironmentPackage.CONTAINER_OPERATING_SYSTEM: |
| 96 | return createContainerOperatingSystemFromString(eDataType, initialValue); |
| 97 | case ResourceenvironmentPackage.SCHEDULING_POLICY: |
| 98 | return createSchedulingPolicyFromString(eDataType, initialValue); |
| 99 | default: |
| 100 | throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * <!-- begin-user-doc --> |
| 106 | * <!-- end-user-doc --> |
| 107 | * @generated |
| 108 | */ |
| 109 | @Override |
| 110 | public String convertToString(EDataType eDataType, Object instanceValue) { |
| 111 | switch (eDataType.getClassifierID()) { |
| 112 | case ResourceenvironmentPackage.CONTAINER_OPERATING_SYSTEM: |
| 113 | return convertContainerOperatingSystemToString(eDataType, instanceValue); |
| 114 | case ResourceenvironmentPackage.SCHEDULING_POLICY: |
| 115 | return convertSchedulingPolicyToString(eDataType, instanceValue); |
| 116 | default: |
| 117 | throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * <!-- begin-user-doc --> |
| 123 | * <!-- end-user-doc --> |
| 124 | * @generated |
| 125 | */ |
| 126 | public ResourceEnvironment createResourceEnvironment() { |
| 127 | ResourceEnvironmentImpl resourceEnvironment = new ResourceEnvironmentImpl(); |
| 128 | return resourceEnvironment; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | public LinkingResource createLinkingResource() { |
| 137 | LinkingResourceImpl linkingResource = new LinkingResourceImpl(); |
| 138 | return linkingResource; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * <!-- begin-user-doc --> |
| 143 | * <!-- end-user-doc --> |
| 144 | * @generated |
| 145 | */ |
| 146 | public ResourceContainer createResourceContainer() { |
| 147 | ResourceContainerImpl resourceContainer = new ResourceContainerImpl(); |
| 148 | return resourceContainer; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * <!-- begin-user-doc --> |
| 153 | * <!-- end-user-doc --> |
| 154 | * @generated |
| 155 | */ |
| 156 | public ProcessingResourceSpecification createProcessingResourceSpecification() { |
| 157 | ProcessingResourceSpecificationImpl processingResourceSpecification = new ProcessingResourceSpecificationImpl(); |
| 158 | return processingResourceSpecification; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * <!-- begin-user-doc --> |
| 163 | * <!-- end-user-doc --> |
| 164 | * @generated |
| 165 | */ |
| 166 | public CommunicationLinkResourceSpecification createCommunicationLinkResourceSpecification() { |
| 167 | CommunicationLinkResourceSpecificationImpl communicationLinkResourceSpecification = new CommunicationLinkResourceSpecificationImpl(); |
| 168 | return communicationLinkResourceSpecification; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * <!-- begin-user-doc --> |
| 173 | * <!-- end-user-doc --> |
| 174 | * @generated |
| 175 | */ |
| 176 | public ContainerOperatingSystem createContainerOperatingSystemFromString(EDataType eDataType, String initialValue) { |
| 177 | ContainerOperatingSystem result = ContainerOperatingSystem.get(initialValue); |
| 178 | if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); |
| 179 | return result; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * <!-- begin-user-doc --> |
| 184 | * <!-- end-user-doc --> |
| 185 | * @generated |
| 186 | */ |
| 187 | public String convertContainerOperatingSystemToString(EDataType eDataType, Object instanceValue) { |
| 188 | return instanceValue == null ? null : instanceValue.toString(); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * <!-- begin-user-doc --> |
| 193 | * <!-- end-user-doc --> |
| 194 | * @generated |
| 195 | */ |
| 196 | public SchedulingPolicy createSchedulingPolicyFromString(EDataType eDataType, String initialValue) { |
| 197 | SchedulingPolicy result = SchedulingPolicy.get(initialValue); |
| 198 | if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); |
| 199 | return result; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * <!-- begin-user-doc --> |
| 204 | * <!-- end-user-doc --> |
| 205 | * @generated |
| 206 | */ |
| 207 | public String convertSchedulingPolicyToString(EDataType eDataType, Object instanceValue) { |
| 208 | return instanceValue == null ? null : instanceValue.toString(); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * <!-- begin-user-doc --> |
| 213 | * <!-- end-user-doc --> |
| 214 | * @generated |
| 215 | */ |
| 216 | public ResourceenvironmentPackage getResourceenvironmentPackage() { |
| 217 | return (ResourceenvironmentPackage)getEPackage(); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * <!-- begin-user-doc --> |
| 222 | * <!-- end-user-doc --> |
| 223 | * @deprecated |
| 224 | * @generated |
| 225 | */ |
| 226 | @Deprecated |
| 227 | public static ResourceenvironmentPackage getPackage() { |
| 228 | return ResourceenvironmentPackage.eINSTANCE; |
| 229 | } |
| 230 | |
| 231 | } //ResourceenvironmentFactoryImpl |