Improved code

This commit is contained in:
Luca Frosini 2020-07-02 18:52:52 +02:00
parent f1d52d3b04
commit ef41afa38d
1 changed files with 20 additions and 19 deletions

View File

@ -82,14 +82,10 @@ public abstract class ElementMapper {
if(!Type.class.isAssignableFrom(clz)) {
Class<Element> dummyClz = accessType.getDummyImplementationClass();
if(dummyClz != null) {
SimpleModule isModule = new SimpleModule(accessType.getName());
isModule.addDeserializer(clz, new ElementDeserializer<>(clz, mapper));
mapper.registerModule(isModule);
ElementMapper.registerSubtypes(dummyClz);
}
/* else {
ElementMapper.registerSubtypes(clz, dummyClz);
}else {
ElementMapper.registerSubtypes(clz);
}*/
}
packages.add(clz.getPackage());
}
@ -123,8 +119,15 @@ public abstract class ElementMapper {
}
}
public static <El extends Element> void registerSubtypes(Class<El>... classes) {
for(Class<El> clz : classes) {
public static <El extends Element> void registerSubtypes(Class<El> clz, Class<El> implementationClass) {
String typeName = TypeMapper.getType(clz);
SimpleModule isModule = new SimpleModule(typeName);
isModule.addDeserializer(clz, new ElementDeserializer<>(clz, mapper));
mapper.registerModule(isModule);
registerSubtypes(implementationClass);
}
public static <El extends Element> void registerSubtypes(Class<El> clz) {
String typeName = TypeMapper.getType(clz);
knownTypes.put(typeName, clz);
@ -134,9 +137,7 @@ public abstract class ElementMapper {
// nameToImplementation.put(typeName, impl);
// }
}
mapper.registerSubtypes(classes);
mapper.registerSubtypes(clz);
}
/**