@Override
void parseObjectSubtype(ObjectData objectData, Map<?, ?> jsonProperties,
Object input) throws JsonProtocolParseException {
if (jsonProperties == null) {
throw new JsonProtocolParseException(
"JSON object input expected for non-manual subtyping");
}
int code = -1;
for (int i = 0; i < this.getSubtypes().size(); i++) {
TypeHandler<?> nextSubtype = this.getSubtypes().get(i).get();
boolean ok = nextSubtype.getSubtypeSupport().checkConditions(jsonProperties);
if (ok) {
if (code == -1) {
code = i;
} else {
throw new JsonProtocolParseException("More than one case match");
}
}
}
if (code == -1) {
if (!this.hasDefaultCase) {
throw new JsonProtocolParseException("Not a singe case matches");
}
} else {
ObjectData fieldData =
this.getSubtypes().get(code).get().parse(input, objectData);
objectData.getFieldArray()[this.variantValueFieldPos] = fieldData;