Class JsonSerializable

    • Constructor Detail

      • JsonSerializable

        protected JsonSerializable()
      • JsonSerializable

        protected JsonSerializable​(String jsonString)
        Constructor.
        Parameters:
        jsonString - the json string that represents the JsonSerializable.
    • Method Detail

      • getLogger

        public org.slf4j.Logger getLogger()
      • getMap

        public Map<String,​Object> getMap()
        Returns the propertybag(JSONObject) in a hashMap
        Returns:
        the HashMap.
      • has

        public boolean has​(String propertyName)
        Checks whether a property exists.
        Parameters:
        propertyName - the property to look up.
        Returns:
        true if the property exists.
      • get

        public Object get​(String propertyName)
        Gets a property value as Object.
        Parameters:
        propertyName - the property to get.
        Returns:
        the value of the property.
      • getString

        public String getString​(String propertyName)
        Gets a string value.
        Parameters:
        propertyName - the property to get.
        Returns:
        the string value.
      • getBoolean

        public Boolean getBoolean​(String propertyName)
        Gets a boolean value.
        Parameters:
        propertyName - the property to get.
        Returns:
        the boolean value.
      • getInt

        public Integer getInt​(String propertyName)
        Gets an integer value.
        Parameters:
        propertyName - the property to get.
        Returns:
        the boolean value
      • getLong

        public Long getLong​(String propertyName)
        Gets a long value.
        Parameters:
        propertyName - the property to get.
        Returns:
        the long value
      • getDouble

        public Double getDouble​(String propertyName)
        Gets a double value.
        Parameters:
        propertyName - the property to get.
        Returns:
        the double value.
      • getObject

        public <T> T getObject​(String propertyName,
                               Class<T> c,
                               boolean... convertFromCamelCase)
        Gets an object value.
        Type Parameters:
        T - the type of the object.
        Parameters:
        propertyName - the property to get.
        c - the class of the object. If c is a POJO class, it must be a member (and not an anonymous or local) and a static one.
        convertFromCamelCase - boolean indicating if String should be converted from camel case to upper case separated by underscore, before converting to required class.
        Returns:
        the object value.
      • getList

        public <T> List<T> getList​(String propertyName,
                                   Class<T> c,
                                   boolean... convertFromCamelCase)
        Gets an object List.
        Type Parameters:
        T - the type of the objects in the List.
        Parameters:
        propertyName - the property to get
        c - the class of the object. If c is a POJO class, it must be a member (and not an anonymous or local) and a static one.
        convertFromCamelCase - boolean indicating if String should be converted from camel case to upper case separated by underscore, before converting to required class.
        Returns:
        the object collection.
      • getCollection

        public <T> Collection<T> getCollection​(String propertyName,
                                               Class<T> c,
                                               boolean... convertFromCamelCase)
        Gets an object collection.
        Type Parameters:
        T - the type of the objects in the collection.
        Parameters:
        propertyName - the property to get
        c - the class of the object. If c is a POJO class, it must be a member (and not an anonymous or local) and a static one.
        convertFromCamelCase - boolean indicating if String should be converted from camel case to upper case separated by underscore, before converting to required class.
        Returns:
        the object collection.
      • getObjectByPath

        public Object getObjectByPath​(List<String> propertyNames)
        Gets the value of a property identified by an array of property names that forms the path.
        Parameters:
        propertyNames - that form the path to the property to get.
        Returns:
        the value of the property.
      • toObject

        public <T> T toObject​(Class<T> c)
        Converts to an Object (only POJOs and JSONObject are supported).
        Type Parameters:
        T - the type of the object.
        Parameters:
        c - the class of the object, either a POJO class or JSONObject. If c is a POJO class, it must be a member (and not an anonymous or local) and a static one.
        Returns:
        the POJO.
      • toJson

        public String toJson()
        Converts to a JSON string.
        Returns:
        the JSON string.
      • toJson

        public String toJson​(SerializationFormattingPolicy formattingPolicy)
        Converts to a JSON string.
        Parameters:
        formattingPolicy - the formatting policy to be used.
        Returns:
        the JSON string.
      • toString

        public String toString()
        Gets Simple STRING representation of property bag. For proper conversion to json and inclusion of the default values use toJson().
        Overrides:
        toString in class Object
        Returns:
        string representation of property bag.