Class JsonObject

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.Object>, Jsonable

    public class JsonObject
    extends java.util.HashMap<java.lang.String,​java.lang.Object>
    implements Jsonable
    JsonObject is a common non-thread safe data format for string to data mappings. The contents of a JsonObject are only validated as JSON values on serialization. Meaning all values added to a JsonObject must be recognized by the Jsoner for it to be a true 'JsonObject', so it is really a JsonableHashMap that will serialize to a JsonObject if all of its contents are valid JSON.
    Since:
    2.0.0
    See Also:
    Jsoner, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonObject()
      Instantiates an empty JsonObject.
      JsonObject​(java.util.Map<java.lang.String,​?> map)
      Instantiate a new JsonObject by accepting a map's entries, which could lead to de/serialization issues of the resulting JsonObject since the entry values aren't validated as JSON values.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.math.BigDecimal getBigDecimal​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getBigDecimal(JsonKey)
      java.math.BigDecimal getBigDecimal​(JsonKey key)
      A convenience method that assumes there is a BigDecimal, Number, or String at the given key.
      java.math.BigDecimal getBigDecimalOrDefault​(java.lang.String key, java.math.BigDecimal defaultValue)
      Deprecated.
      java.math.BigDecimal getBigDecimalOrDefault​(JsonKey key)
      A convenience method that assumes there is a BigDecimal, Number, or String at the given key.
      java.lang.Boolean getBoolean​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getBoolean(JsonKey)
      java.lang.Boolean getBoolean​(JsonKey key)
      A convenience method that assumes there is a Boolean or String value at the given key.
      java.lang.Boolean getBooleanOrDefault​(java.lang.String key, boolean defaultValue)
      Deprecated.
      java.lang.Boolean getBooleanOrDefault​(JsonKey key)
      A convenience method that assumes there is a Boolean or String value at the given key.
      java.lang.Byte getByte​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getByte(JsonKey)
      java.lang.Byte getByte​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Byte getByteOrDefault​(java.lang.String key, byte defaultValue)
      Deprecated.
      2.3.0 in favor of getByteOrDefault(JsonKey)
      java.lang.Byte getByteOrDefault​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      <T extends java.util.Collection<?>>
      T
      getCollection​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getCollection(JsonKey)
      <T extends java.util.Collection<?>>
      T
      getCollection​(JsonKey key)
      A convenience method that assumes there is a Collection at the given key.
      <T extends java.util.Collection<?>>
      T
      getCollectionOrDefault​(java.lang.String key, T defaultValue)
      Deprecated.
      <T extends java.util.Collection<?>>
      T
      getCollectionOrDefault​(JsonKey key)
      A convenience method that assumes there is a Collection at the given key.
      java.lang.Double getDouble​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getDouble(JsonKey)
      java.lang.Double getDouble​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Double getDoubleOrDefault​(java.lang.String key, double defaultValue)
      Deprecated.
      2.3.0 in favor of getDoubleOrDefault(JsonKey)
      java.lang.Double getDoubleOrDefault​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      <T extends java.lang.Enum<T>>
      T
      getEnum​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getEnum(JsonKey)
      <T extends java.lang.Enum<T>>
      T
      getEnum​(JsonKey key)
      Deprecated.
      2.3.0 Jsoner deprecated automatically serializing enums as Strings.
      <T extends java.lang.Enum<T>>
      T
      getEnumOrDefault​(java.lang.String key, T defaultValue)
      Deprecated.
      2.3.0 in favor of getEnumOrDefault(JsonKey)
      <T extends java.lang.Enum<T>>
      T
      getEnumOrDefault​(JsonKey key)
      Deprecated.
      2.3.0 Jsoner deprecated automatically serializing enums as Strings.
      java.lang.Float getFloat​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getFloat(JsonKey)
      java.lang.Float getFloat​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Float getFloatOrDefault​(java.lang.String key, float defaultValue)
      Deprecated.
      2.3.0 in favor of getFloatOrDefault(JsonKey)
      java.lang.Float getFloatOrDefault​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Integer getInteger​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getInteger(JsonKey)
      java.lang.Integer getInteger​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Integer getIntegerOrDefault​(java.lang.String key, int defaultValue)
      Deprecated.
      java.lang.Integer getIntegerOrDefault​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Long getLong​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getLong(JsonKey)
      java.lang.Long getLong​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Long getLongOrDefault​(java.lang.String key, long defaultValue)
      Deprecated.
      2.3.0 in favor of getLongOrDefault(JsonKey)
      java.lang.Long getLongOrDefault​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      <T extends java.util.Map<?,​?>>
      T
      getMap​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getMap(JsonKey)
      <T extends java.util.Map<?,​?>>
      T
      getMap​(JsonKey key)
      A convenience method that assumes there is a Map at the given key.
      <T extends java.util.Map<?,​?>>
      T
      getMapOrDefault​(java.lang.String key, T defaultValue)
      Deprecated.
      2.3.0 in favor of getMapOrDefault(JsonKey)
      <T extends java.util.Map<?,​?>>
      T
      getMapOrDefault​(JsonKey key)
      A convenience method that assumes there is a Map at the given key.
      java.lang.Short getShort​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getShort(JsonKey)
      java.lang.Short getShort​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.Short getShortOrDefault​(java.lang.String key, short defaultValue)
      Deprecated.
      2.3.0 in favor of getShortOrDefault(JsonKey)
      java.lang.Short getShortOrDefault​(JsonKey key)
      A convenience method that assumes there is a Number or String value at the given key.
      java.lang.String getString​(java.lang.String key)
      Deprecated.
      2.3.0 in favor of getString(JsonKey)
      java.lang.String getString​(JsonKey key)
      A convenience method that assumes there is a Boolean, Number, or String value at the given key.
      java.lang.String getStringOrDefault​(java.lang.String key, java.lang.String defaultValue)
      Deprecated.
      2.3.0 in favor of getStringOrDefault(JsonKey)
      java.lang.String getStringOrDefault​(JsonKey key)
      A convenience method that assumes there is a Boolean, Number, or String value at the given key.
      void requireKeys​(JsonKey... keys)
      Ensures the given keys are present.
      java.lang.String toJson()
      Serialize to a JSON formatted string.
      void toJson​(java.io.Writer writable)
      Serialize to a JSON formatted stream.
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Constructor Detail

      • JsonObject

        public JsonObject()
        Instantiates an empty JsonObject.
      • JsonObject

        public JsonObject​(java.util.Map<java.lang.String,​?> map)
        Instantiate a new JsonObject by accepting a map's entries, which could lead to de/serialization issues of the resulting JsonObject since the entry values aren't validated as JSON values.
        Parameters:
        map - represents the mappings to produce the JsonObject with.
    • Method Detail

      • requireKeys

        public void requireKeys​(JsonKey... keys)
        Ensures the given keys are present.
        Parameters:
        keys - represents the keys that must be present.
        Throws:
        java.util.NoSuchElementException - if any of the given keys are missing.
        Since:
        2.3.0 to ensure critical keys are in the JsonObject.
      • getBigDecimal

        public java.math.BigDecimal getBigDecimal​(JsonKey key)
        A convenience method that assumes there is a BigDecimal, Number, or String at the given key. If a Number is there its Number#toString() is used to construct a new BigDecimal(String). If a String is there it is used to construct a new BigDecimal(String).
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a BigDecimal representing the value paired with the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        BigDecimal, Object.toString(), JsonKey
      • getBigDecimal

        @Deprecated
        public java.math.BigDecimal getBigDecimal​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getBigDecimal(JsonKey)
        A convenience method that assumes there is a BigDecimal, Number, or String at the given key. If a Number is there its Number#toString() is used to construct a new BigDecimal(String). If a String is there it is used to construct a new BigDecimal(String).
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        BigDecimal, Object.toString()
      • getBigDecimalOrDefault

        public java.math.BigDecimal getBigDecimalOrDefault​(JsonKey key)
        A convenience method that assumes there is a BigDecimal, Number, or String at the given key. If a Number is there its Number#toString() is used to construct a new BigDecimal(String). If a String is there it is used to construct a new BigDecimal(String).
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a BigDecimal representing the value paired with the key or JsonKey#getValue() if the key isn't present.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        BigDecimal, Object.toString(), JsonKey
      • getBigDecimalOrDefault

        @Deprecated
        public java.math.BigDecimal getBigDecimalOrDefault​(java.lang.String key,
                                                           java.math.BigDecimal defaultValue)
        Deprecated.
        A convenience method that assumes there is a BigDecimal, Number, or String at the given key. If a Number is there its Number#toString() is used to construct a new BigDecimal(String). If a String is there it is used to construct a new BigDecimal(String).
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return types.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        BigDecimal, Object.toString()
      • getBoolean

        public java.lang.Boolean getBoolean​(JsonKey key)
        A convenience method that assumes there is a Boolean or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Boolean representing the value paired with the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getBoolean

        @Deprecated
        public java.lang.Boolean getBoolean​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getBoolean(JsonKey)
        A convenience method that assumes there is a Boolean or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
      • getBooleanOrDefault

        public java.lang.Boolean getBooleanOrDefault​(JsonKey key)
        A convenience method that assumes there is a Boolean or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Boolean representing the value paired with the key or JsonKey#getValue() if the key isn't present.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getBooleanOrDefault

        @Deprecated
        public java.lang.Boolean getBooleanOrDefault​(java.lang.String key,
                                                     boolean defaultValue)
        Deprecated.
        A convenience method that assumes there is a Boolean or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
      • getByte

        public java.lang.Byte getByte​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Byte representing the value paired with the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.byteValue(), JsonKey
      • getByte

        @Deprecated
        public java.lang.Byte getByte​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getByte(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.byteValue()
      • getByteOrDefault

        public java.lang.Byte getByteOrDefault​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Byte representing the value paired with the key or JsonKey#getValue() if the key isn't present (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.byteValue(), JsonKey
      • getByteOrDefault

        @Deprecated
        public java.lang.Byte getByteOrDefault​(java.lang.String key,
                                               byte defaultValue)
        Deprecated.
        2.3.0 in favor of getByteOrDefault(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key (which may involve rounding or truncation) or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.byteValue()
      • getCollection

        public <T extends java.util.Collection<?>> T getCollection​(JsonKey key)
        A convenience method that assumes there is a Collection at the given key.
        Type Parameters:
        T - the kind of collection to expect at the key. Note unless manually added, collection values will be a JsonArray.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Collection representing the value paired with the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getCollection

        @Deprecated
        public <T extends java.util.Collection<?>> T getCollection​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getCollection(JsonKey)
        A convenience method that assumes there is a Collection at the given key.
        Type Parameters:
        T - the kind of collection to expect at the key. Note unless manually added, collection values will be a JsonArray.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
      • getCollectionOrDefault

        public <T extends java.util.Collection<?>> T getCollectionOrDefault​(JsonKey key)
        A convenience method that assumes there is a Collection at the given key.
        Type Parameters:
        T - the kind of collection to expect at the key. Note unless manually added, collection values will be a JsonArray.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Collection representing the value paired with the key or JsonKey#getValue() if the key isn't present..
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getCollectionOrDefault

        @Deprecated
        public <T extends java.util.Collection<?>> T getCollectionOrDefault​(java.lang.String key,
                                                                            T defaultValue)
        Deprecated.
        A convenience method that assumes there is a Collection at the given key.
        Type Parameters:
        T - the kind of collection to expect at the key. Note unless manually added, collection values will be a JsonArray.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
      • getDouble

        public java.lang.Double getDouble​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Double representing the value paired with the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.doubleValue(), JsonKey
      • getDouble

        @Deprecated
        public java.lang.Double getDouble​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getDouble(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.doubleValue()
      • getDoubleOrDefault

        public java.lang.Double getDoubleOrDefault​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Double representing the value paired with the key or JsonKey#getValue() if the key isn't present (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.doubleValue(), JsonKey
      • getDoubleOrDefault

        @Deprecated
        public java.lang.Double getDoubleOrDefault​(java.lang.String key,
                                                   double defaultValue)
        Deprecated.
        2.3.0 in favor of getDoubleOrDefault(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key (which may involve rounding or truncation) or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.doubleValue()
      • getEnum

        @Deprecated
        public <T extends java.lang.Enum<T>> T getEnum​(JsonKey key)
                                                throws java.lang.ClassNotFoundException
        Deprecated.
        2.3.0 Jsoner deprecated automatically serializing enums as Strings.
        A convenience method that assumes there is a String value at the given key representing a fully qualified name in dot notation of an enum.
        Type Parameters:
        T - the Enum type the value at the key is expected to belong to.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        an Enum representing the value paired with the key.
        Throws:
        java.lang.ClassNotFoundException - if the value was a String but the declaring enum type couldn't be determined with it.
        java.lang.ClassCastException - if the element at the index was not a String or if the fully qualified enum name is of the wrong type.
        java.lang.IllegalArgumentException - if an enum type was determined but it doesn't define an enum with the determined name.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Enum.valueOf(Class, String), JsonKey
      • getEnum

        @Deprecated
        public <T extends java.lang.Enum<T>> T getEnum​(java.lang.String key)
                                                throws java.lang.ClassNotFoundException
        Deprecated.
        2.3.0 in favor of getEnum(JsonKey)
        A convenience method that assumes there is a String value at the given key representing a fully qualified name in dot notation of an enum.
        Type Parameters:
        T - the Enum type the value at the key is expected to belong to.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the enum based on the string found at the key, or null if the value paired with the provided key is null.
        Throws:
        java.lang.ClassNotFoundException - if the value was a String but the declaring enum type couldn't be determined with it.
        java.lang.ClassCastException - if the element at the index was not a String or if the fully qualified enum name is of the wrong type.
        java.lang.IllegalArgumentException - if an enum type was determined but it doesn't define an enum with the determined name.
        See Also:
        Enum.valueOf(Class, String)
      • getEnumOrDefault

        @Deprecated
        public <T extends java.lang.Enum<T>> T getEnumOrDefault​(JsonKey key)
                                                         throws java.lang.ClassNotFoundException
        Deprecated.
        2.3.0 Jsoner deprecated automatically serializing enums as Strings.
        A convenience method that assumes there is a String value at the given key representing a fully qualified name in dot notation of an enum.
        Type Parameters:
        T - the Enum type the value at the key is expected to belong to.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        an Enum representing the value paired with the key or JsonKey#getValue() if the key isn't present.
        Throws:
        java.lang.ClassNotFoundException - if the value was a String but the declaring enum type couldn't be determined with it.
        java.lang.ClassCastException - if the element at the index was not a String or if the fully qualified enum name is of the wrong type.
        java.lang.IllegalArgumentException - if an enum type was determined but it doesn't define an enum with the determined name.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Enum.valueOf(Class, String), JsonKey
      • getEnumOrDefault

        @Deprecated
        public <T extends java.lang.Enum<T>> T getEnumOrDefault​(java.lang.String key,
                                                                T defaultValue)
                                                         throws java.lang.ClassNotFoundException
        Deprecated.
        2.3.0 in favor of getEnumOrDefault(JsonKey)
        A convenience method that assumes there is a String value at the given key representing a fully qualified name in dot notation of an enum.
        Type Parameters:
        T - the Enum type the value at the key is expected to belong to.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the enum based on the string found at the key, or the defaultValue provided if the key doesn't exist, or null if the value paired with provided key is null.
        Throws:
        java.lang.ClassNotFoundException - if the value was a String but the declaring enum type couldn't be determined with it.
        java.lang.ClassCastException - if the element at the index was not a String or if the fully qualified enum name is of the wrong type.
        java.lang.IllegalArgumentException - if an enum type was determined but it doesn't define an enum with the determined name.
        See Also:
        Enum.valueOf(Class, String)
      • getFloat

        public java.lang.Float getFloat​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Float representing the value paired with the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.floatValue(), JsonKey
      • getFloat

        @Deprecated
        public java.lang.Float getFloat​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getFloat(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.floatValue()
      • getFloatOrDefault

        public java.lang.Float getFloatOrDefault​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Float representing the value paired with the key or JsonKey#getValue() if the key isn't present (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.floatValue(), JsonKey
      • getFloatOrDefault

        @Deprecated
        public java.lang.Float getFloatOrDefault​(java.lang.String key,
                                                 float defaultValue)
        Deprecated.
        2.3.0 in favor of getFloatOrDefault(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key (which may involve rounding or truncation) or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.floatValue()
      • getInteger

        public java.lang.Integer getInteger​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        an Integer representing the value paired with the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.intValue(), JsonKey
      • getInteger

        @Deprecated
        public java.lang.Integer getInteger​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getInteger(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.intValue()
      • getIntegerOrDefault

        public java.lang.Integer getIntegerOrDefault​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        an Integer representing the value paired with the key or JsonKey#getValue() if the key isn't present (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.intValue(), JsonKey
      • getIntegerOrDefault

        @Deprecated
        public java.lang.Integer getIntegerOrDefault​(java.lang.String key,
                                                     int defaultValue)
        Deprecated.
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key (which may involve rounding or truncation) or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.intValue()
      • getLong

        public java.lang.Long getLong​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Long representing the value paired with the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.longValue(), JsonKey
      • getLong

        @Deprecated
        public java.lang.Long getLong​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getLong(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.longValue()
      • getLongOrDefault

        public java.lang.Long getLongOrDefault​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Long representing the value paired with the key or JsonKey#getValue() if the key isn't present (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.longValue(), JsonKey
      • getLongOrDefault

        @Deprecated
        public java.lang.Long getLongOrDefault​(java.lang.String key,
                                               long defaultValue)
        Deprecated.
        2.3.0 in favor of getLongOrDefault(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key (which may involve rounding or truncation) or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.longValue()
      • getMap

        public <T extends java.util.Map<?,​?>> T getMap​(JsonKey key)
        A convenience method that assumes there is a Map at the given key.
        Type Parameters:
        T - the kind of map to expect at the key. Note unless manually added, Map values will be a JsonObject.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Map representing the value paired with the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getMap

        @Deprecated
        public <T extends java.util.Map<?,​?>> T getMap​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getMap(JsonKey)
        A convenience method that assumes there is a Map at the given key.
        Type Parameters:
        T - the kind of map to expect at the key. Note unless manually added, Map values will be a JsonObject.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
      • getMapOrDefault

        public <T extends java.util.Map<?,​?>> T getMapOrDefault​(JsonKey key)
        A convenience method that assumes there is a Map at the given key.
        Type Parameters:
        T - the kind of map to expect at the key. Note unless manually added, Map values will be a JsonObject.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Map representing the value paired with the key or JsonKey#getValue() if the key isn't present.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getMapOrDefault

        @Deprecated
        public <T extends java.util.Map<?,​?>> T getMapOrDefault​(java.lang.String key,
                                                                      T defaultValue)
        Deprecated.
        2.3.0 in favor of getMapOrDefault(JsonKey)
        A convenience method that assumes there is a Map at the given key.
        Type Parameters:
        T - the kind of map to expect at the key. Note unless manually added, Map values will be a JsonObject.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
      • getShort

        public java.lang.Short getShort​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Short representing the value paired with the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.shortValue(), JsonKey
      • getShort

        @Deprecated
        public java.lang.Short getShort​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getShort(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.shortValue()
      • getShortOrDefault

        public java.lang.Short getShortOrDefault​(JsonKey key)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a Short representing the value paired with the key or JsonKey#getValue() if the key isn't present (which may involve rounding or truncation).
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        Number.shortValue(), JsonKey
      • getShortOrDefault

        @Deprecated
        public java.lang.Short getShortOrDefault​(java.lang.String key,
                                                 short defaultValue)
        Deprecated.
        2.3.0 in favor of getShortOrDefault(JsonKey)
        A convenience method that assumes there is a Number or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key (which may involve rounding or truncation) or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
        java.lang.NumberFormatException - if a String isn't a valid representation of a BigDecimal or if the Number represents the double or float Infinity or NaN.
        See Also:
        Number.shortValue()
      • getString

        public java.lang.String getString​(JsonKey key)
        A convenience method that assumes there is a Boolean, Number, or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a String representing the value paired with the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getString

        @Deprecated
        public java.lang.String getString​(java.lang.String key)
        Deprecated.
        2.3.0 in favor of getString(JsonKey)
        A convenience method that assumes there is a Boolean, Number, or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        Returns:
        the value stored at the key.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
      • getStringOrDefault

        public java.lang.String getStringOrDefault​(JsonKey key)
        A convenience method that assumes there is a Boolean, Number, or String value at the given key.
        Parameters:
        key - representing where the value ought to be paired with.
        Returns:
        a String representing the value paired with the key or JsonKey#getValue() if the key isn't present.
        Throws:
        java.lang.ClassCastException - if the value didn't match the assumed return type.
        Since:
        2.3.0 to utilize JsonKey
        See Also:
        JsonKey
      • getStringOrDefault

        @Deprecated
        public java.lang.String getStringOrDefault​(java.lang.String key,
                                                   java.lang.String defaultValue)
        Deprecated.
        2.3.0 in favor of getStringOrDefault(JsonKey)
        A convenience method that assumes there is a Boolean, Number, or String value at the given key.
        Parameters:
        key - representing where the value ought to be stored at.
        defaultValue - representing what is returned when the key isn't in the JsonObject.
        Returns:
        the value stored at the key or the default provided if the key doesn't exist.
        Throws:
        java.lang.ClassCastException - if there was a value but didn't match the assumed return type.
      • toJson

        public java.lang.String toJson()
        Description copied from interface: Jsonable
        Serialize to a JSON formatted string.
        Specified by:
        toJson in interface Jsonable
        Returns:
        a string, formatted in JSON, that represents the Jsonable.
      • toJson

        public void toJson​(java.io.Writer writable)
                    throws java.io.IOException
        Description copied from interface: Jsonable
        Serialize to a JSON formatted stream.
        Specified by:
        toJson in interface Jsonable
        Parameters:
        writable - where the resulting JSON text should be sent.
        Throws:
        java.io.IOException - when the writable encounters an I/O error.