X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonReturnObject.java;h=ca29f3c1b4a557995827d58e16ec7883a79d6955;hp=3b237da9eb654c722b1aaf4a57d58215cb062c68;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=9fbafff8f3467329e7c8ad24d5d13273962ade28 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 3b237da..ca29f3c 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java @@ -6,12 +6,13 @@ 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; import com.fasterxml.jackson.databind.node.TextNode; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; /** @@ -26,7 +27,6 @@ public class JsonReturnObject { private final boolean success; /** The returned values. */ - @JsonUnwrapped private final Map content = Maps.newHashMap(); /** @@ -40,6 +40,43 @@ public class JsonReturnObject { } // + // ACCESSORS + // + + /** + * Returns whether the request was successful. + * + * @return {@code true} if the request was successful, {@code false} otherwise + */ + @VisibleForTesting + public boolean isSuccess() { + return success; + } + + /** + * Returns the value stored under the given key. + * + * @param key + * The key of the value to retrieve + * @return The value of the key, or {@code null} if there is no value for the + * given key + */ + @VisibleForTesting + public JsonNode get(String key) { + 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 //