Default to empty if map is empty in serializer
This commit is contained in:
parent
d849041604
commit
80b11bfc6a
@ -105,8 +105,17 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Jso
|
|||||||
if (opt instanceof ParameterizedType) {
|
if (opt instanceof ParameterizedType) {
|
||||||
Type val = ((ParameterizedType) opt).getActualTypeArguments()[0];
|
Type val = ((ParameterizedType) opt).getActualTypeArguments()[0];
|
||||||
|
|
||||||
entry.setValue(Optional.of(
|
Optional value;
|
||||||
gson.fromJson(gson.toJson(((LinkedTreeMap) entry.getValue()).get("value")), val)));
|
|
||||||
|
if (((LinkedTreeMap) entry.getValue()).isEmpty()) {
|
||||||
|
value = Optional.empty();
|
||||||
|
} else {
|
||||||
|
value = Optional
|
||||||
|
.of(gson.fromJson(gson.toJson(((LinkedTreeMap) entry.getValue()).get("value")),
|
||||||
|
val));
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.setValue(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user