Fix polymorphism adapters
This commit is contained in:
parent
135d71bb44
commit
99c410c21c
@ -58,17 +58,22 @@ public abstract class MoshiPolymorphic<OBJ> {
|
||||
for (Class<?> declaredClass : abstractClasses) {
|
||||
var name = fixType(declaredClass.getSimpleName());
|
||||
JsonAdapter<OBJ> adapter = new PolymorphicAdapter<>(name);
|
||||
abstractClassesSerializers.put(declaredClass, adapter);
|
||||
if (!extraClassesSerializers.containsKey(declaredClass)) {
|
||||
abstractMoshiBuilder.add(declaredClass, adapter);
|
||||
abstractClassesSerializers.put(declaredClass, adapter);
|
||||
}
|
||||
customAdapters.put(name, adapter);
|
||||
abstractMoshiBuilder.add(declaredClass, adapter);
|
||||
}
|
||||
|
||||
for (Class<?> declaredClass : concreteClasses) {
|
||||
var name = fixType(declaredClass.getSimpleName());
|
||||
JsonAdapter<OBJ> adapter = new NormalValueAdapter<>(name, declaredClass);
|
||||
concreteClassesSerializers.put(declaredClass, adapter);
|
||||
if (!extraClassesSerializers.containsKey(declaredClass)
|
||||
&& !abstractClassesSerializers.containsKey(declaredClass)) {
|
||||
concreteClassesSerializers.put(declaredClass, adapter);
|
||||
abstractMoshiBuilder.add(declaredClass, adapter);
|
||||
}
|
||||
customAdapters.put(name, adapter);
|
||||
abstractMoshiBuilder.add(declaredClass, adapter);
|
||||
}
|
||||
|
||||
abstractMoshiBuilder.addLast(new RecordsJsonAdapterFactory());
|
||||
|
Loading…
x
Reference in New Issue
Block a user