X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonReturnObject.java;h=45bbb4f7fb9cc80af2a125eb48544b14a06060c8;hb=959d2b0a4c4636c73d531d1097f062bf5f8e3edf;hp=61616160b36b743edb609806d7009d7c5d9bb014;hpb=27ab81aa28054c2e184cf16bcec03f2fac7475e5;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java index 6161616..45bbb4f 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java @@ -6,8 +6,8 @@ package net.pterodactylus.sone.web.ajax; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; @@ -27,7 +27,6 @@ public class JsonReturnObject { private final boolean success; /** The returned values. */ - @JsonUnwrapped private final Map content = Maps.newHashMap(); /** @@ -67,6 +66,16 @@ public class JsonReturnObject { return content.get(key); } + /** + * Returns the content of this object for serialization. + * + * @return The content of this object + */ + @JsonAnyGetter + public Map getContent() { + return content; + } + // // ACTIONS // @@ -107,7 +116,7 @@ public class JsonReturnObject { * @return This JSON return object */ public JsonReturnObject put(String key, String value) { - return put(key, new TextNode(value)); + return put(key, TextNode.valueOf(value)); } /** @@ -124,4 +133,18 @@ public class JsonReturnObject { return this; } + @Override + public int hashCode() { + return Boolean.valueOf(success).hashCode() ^ content.hashCode(); + } + + @Override + public boolean equals(Object object) { + if ((object == null) || (object.getClass() != getClass())) { + return false; + } + JsonReturnObject other = (JsonReturnObject) object; + return (success == other.success) && content.equals(other.content); + } + }