Improved unmarshalling in ElementMapper

This commit is contained in:
Luca Frosini 2023-05-17 18:12:34 +02:00
parent f9137ffff9
commit 1368f707c8
1 changed files with 29 additions and 9 deletions

View File

@ -312,7 +312,11 @@ public abstract class ElementMapper {
}
JsonNode jsonNode = mapper.readTree(reader);
jsonNode = analizeTypes((ObjectNode) jsonNode);
try {
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
}catch (Throwable t) {
throw e;
}
}
}
@ -336,7 +340,11 @@ public abstract class ElementMapper {
}
JsonNode jsonNode = mapper.readTree(stream);
jsonNode = analizeTypes((ObjectNode) jsonNode);
try {
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
}catch (Throwable t) {
throw e;
}
}
}
@ -359,7 +367,11 @@ public abstract class ElementMapper {
}
JsonNode jsonNode = mapper.readTree(string);
jsonNode = analizeTypes((ObjectNode) jsonNode);
try {
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
}catch (Throwable t) {
throw e;
}
}
}
@ -374,10 +386,14 @@ public abstract class ElementMapper {
}
List<El> ret = new ArrayList<>();
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
try {
for(JsonNode jsonNode : arrayNode) {
jsonNode = analizeTypes((ObjectNode) jsonNode);
ret.add(ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode)));
}
}catch (Throwable t) {
throw e;
}
return ret;
}
}
@ -390,10 +406,14 @@ public abstract class ElementMapper {
} catch (InvalidTypeIdException e) {
List<El> ret = new ArrayList<>();
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
try {
for(JsonNode jsonNode : arrayNode) {
jsonNode = analizeTypes((ObjectNode) jsonNode);
ret.add((El) ElementMapper.unmarshal(Element.class, mapper.writeValueAsString(jsonNode)));
}
}catch (Throwable t) {
throw e;
}
return ret;
}
}