Skip to content

Commit

Permalink
WIP - Build problem analysis - Add InstanceEvents to Jackson module
Browse files Browse the repository at this point in the history
  • Loading branch information
srempfer committed Apr 28, 2020
1 parent 53ce34a commit 98be6ef
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,37 @@ public Registration deserialize(JsonParser p, DeserializationContext ctxt) throw
JsonNode node = p.readValueAsTree();
Registration.Builder builder = Registration.builder();

if (node.has("name")) {
if (node.hasNonNull("name")) {
builder.name(node.get("name").asText());
}
if (node.has("url")) {
if (node.hasNonNull("url")) {
String url = node.get("url").asText();
builder.healthUrl(url.replaceFirst("/+$", "") + "/health").managementUrl(url);
}
else {
if (node.has("healthUrl")) {
if (node.hasNonNull("healthUrl")) {
builder.healthUrl(node.get("healthUrl").asText());
}
if (node.has("managementUrl")) {
if (node.hasNonNull("managementUrl")) {
builder.managementUrl(node.get("managementUrl").asText());
}
if (node.has("serviceUrl")) {
if (node.hasNonNull("serviceUrl")) {
builder.serviceUrl(node.get("serviceUrl").asText());
}
}

if (node.has("metadata")) {
if (node.hasNonNull("metadata")) {
Iterator<Map.Entry<String, JsonNode>> it = node.get("metadata").fields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
builder.metadata(entry.getKey(), entry.getValue().asText());
}
}

if (node.hasNonNull("source")) {
builder.source(node.get("source").asText());
}

return builder.build();
}

Expand Down

0 comments on commit 98be6ef

Please sign in to comment.