Introduced a factory for codegen data containers

implementation completed
This commit is contained in:
Martin Ehrnhoefer 2014-12-07 09:52:52 +01:00
parent f4424a5eae
commit 0eb467e46e

View File

@ -24,10 +24,11 @@ public final class CodegenModelFactory {
typeMapping.put(type, implementation);
}
@SuppressWarnings("unchecked")
public static <T> T newInstance(CodegenModelType type) {
@SuppressWarnings("unchecked") Class<T> classType = (Class<T>) typeMapping.get(type);
Class<?> classType = typeMapping.get(type);
try {
return classType.newInstance();
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {