forked from loafle/openapi-generator-original
Introduced a factory for codegen data containers
implementation completed
This commit is contained in:
parent
f4424a5eae
commit
0eb467e46e
@ -24,10 +24,11 @@ public final class CodegenModelFactory {
|
|||||||
typeMapping.put(type, implementation);
|
typeMapping.put(type, implementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T newInstance(CodegenModelType type) {
|
public static <T> T newInstance(CodegenModelType type) {
|
||||||
@SuppressWarnings("unchecked") Class<T> classType = (Class<T>) typeMapping.get(type);
|
Class<?> classType = typeMapping.get(type);
|
||||||
try {
|
try {
|
||||||
return classType.newInstance();
|
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user