1 17 package org.eclipse.emf.codegen.ecore.genmodel.impl; 18 19 20 import org.eclipse.emf.codegen.ecore.genmodel.*; 21 import org.eclipse.emf.ecore.EClass; 22 import org.eclipse.emf.ecore.EDataType; 23 import org.eclipse.emf.ecore.EObject; 24 import org.eclipse.emf.ecore.impl.EFactoryImpl; 25 26 27 33 public class GenModelFactoryImpl extends EFactoryImpl implements GenModelFactory 34 { 35 41 public GenModelFactoryImpl() 42 { 43 super(); 44 } 45 46 51 public EObject create(EClass eClass) 52 { 53 switch (eClass.getClassifierID()) 54 { 55 case GenModelPackage.GEN_MODEL: return createGenModel(); 56 case GenModelPackage.GEN_PACKAGE: return createGenPackage(); 57 case GenModelPackage.GEN_CLASS: return createGenClass(); 58 case GenModelPackage.GEN_FEATURE: return createGenFeature(); 59 case GenModelPackage.GEN_ENUM: return createGenEnum(); 60 case GenModelPackage.GEN_ENUM_LITERAL: return createGenEnumLiteral(); 61 case GenModelPackage.GEN_DATA_TYPE: return createGenDataType(); 62 case GenModelPackage.GEN_OPERATION: return createGenOperation(); 63 case GenModelPackage.GEN_PARAMETER: return createGenParameter(); 64 default: 65 throw new IllegalArgumentException ("The class '" + eClass.getName() + "' is not a valid classifier"); 66 } 67 } 68 69 74 public Object createFromString(EDataType eDataType, String initialValue) 75 { 76 switch (eDataType.getClassifierID()) 77 { 78 case GenModelPackage.GEN_PROVIDER_KIND: 79 { 80 GenProviderKind result = GenProviderKind.get(initialValue); 81 if (result == null) throw new IllegalArgumentException ("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); 82 return result; 83 } 84 case GenModelPackage.GEN_PROPERTY_KIND: 85 { 86 GenPropertyKind result = GenPropertyKind.get(initialValue); 87 if (result == null) throw new IllegalArgumentException ("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); 88 return result; 89 } 90 case GenModelPackage.GEN_RESOURCE_KIND: 91 { 92 GenResourceKind result = GenResourceKind.get(initialValue); 93 if (result == null) throw new IllegalArgumentException ("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); 94 return result; 95 } 96 default: 97 throw new IllegalArgumentException ("The datatype '" + eDataType.getName() + "' is not a valid classifier"); 98 } 99 } 100 101 106 public String convertToString(EDataType eDataType, Object instanceValue) 107 { 108 switch (eDataType.getClassifierID()) 109 { 110 case GenModelPackage.GEN_PROVIDER_KIND: 111 return instanceValue == null ? null : instanceValue.toString(); 112 case GenModelPackage.GEN_PROPERTY_KIND: 113 return instanceValue == null ? null : instanceValue.toString(); 114 case GenModelPackage.GEN_RESOURCE_KIND: 115 return instanceValue == null ? null : instanceValue.toString(); 116 default: 117 throw new IllegalArgumentException ("The datatype '" + eDataType.getName() + "' is not a valid classifier"); 118 } 119 } 120 121 126 public GenModel createGenModel() 127 { 128 GenModelImpl genModel = new GenModelImpl(); 129 return genModel; 130 } 131 132 137 public GenPackage createGenPackage() 138 { 139 GenPackageImpl genPackage = new GenPackageImpl(); 140 return genPackage; 141 } 142 143 148 public GenClass createGenClass() 149 { 150 GenClassImpl genClass = new GenClassImpl(); 151 return genClass; 152 } 153 154 159 public GenFeature createGenFeature() 160 { 161 GenFeatureImpl genFeature = new GenFeatureImpl(); 162 return genFeature; 163 } 164 165 170 public GenEnum createGenEnum() 171 { 172 GenEnumImpl genEnum = new GenEnumImpl(); 173 return genEnum; 174 } 175 176 181 public GenEnumLiteral createGenEnumLiteral() 182 { 183 GenEnumLiteralImpl genEnumLiteral = new GenEnumLiteralImpl(); 184 return genEnumLiteral; 185 } 186 187 192 public GenDataType createGenDataType() 193 { 194 GenDataTypeImpl genDataType = new GenDataTypeImpl(); 195 return genDataType; 196 } 197 198 203 public GenOperation createGenOperation() 204 { 205 GenOperationImpl genOperation = new GenOperationImpl(); 206 return genOperation; 207 } 208 209 214 public GenParameter createGenParameter() 215 { 216 GenParameterImpl genParameter = new GenParameterImpl(); 217 return genParameter; 218 } 219 220 225 public GenModelPackage getGenModelPackage() 226 { 227 return (GenModelPackage)getEPackage(); 228 } 229 230 236 public static GenModelPackage getPackage() 237 { 238 return GenModelPackage.eINSTANCE; 239 } 240 241 } | Popular Tags |