Class AttributeableEntity

    • Constructor Detail

      • AttributeableEntity

        public AttributeableEntity()
    • Method Detail

      • setDefaults

        protected void setDefaults()
        Apply the non-null default values.
      • clear

        public void clear()
        Clear the object and reset to defaults
      • toJSONObject

        public javax.json.JsonObject toJSONObject()
                                           throws IOException
        Convert this object into JSON
        Returns:
        The json object
        Throws:
        IOException - If generating the JSON fails
      • fromJSONObject

        public void fromJSONObject​(javax.json.JsonObject jsonObj)
                            throws IOException
        Extract the metadata from the JSON object. This method first calls clear()
        Parameters:
        jsonObj - The JSON Object
        Throws:
        IOException - If JSON parsing fails
      • getAttributes

        public Map<String,​javax.json.JsonValue> getAttributes()
        Get the attributes
        Returns:
        Mutable map of attributes, by attribute name
      • createJson

        protected javax.json.JsonObjectBuilder createJson()
                                                   throws IOException
        Convert this object into JSON
        Returns:
        The json object builder
        Throws:
        IOException - If generating the JSON fails
      • getString

        protected String getString​(javax.json.JsonValue jsonValue)
        Helper method to get a string value from a JsonValue
        Parameters:
        jsonValue - The json value
        Returns:
        The string value or null.
      • getString

        protected String getString​(String attributeName)
        Helper method to get a string value from an attribute
        Parameters:
        attributeName - The attribute name
        Returns:
        The string value or null.
      • getStringArray

        protected String[] getStringArray​(String attributeName)
                                   throws IOException
        Helper method to get a string array from an attribute
        Parameters:
        attributeName - The attribute name
        Returns:
        The string array or null.
        Throws:
        IOException
        Since:
        1.6.0
      • getNumber

        protected Number getNumber​(String attributeName)
                            throws IOException
        Helper method to get a number value from an attribute
        Parameters:
        attributeName - The attribute name
        Returns:
        The string value or null.
        Throws:
        IOException - If the attribute value is not of type boolean
      • setString

        protected void setString​(javax.json.JsonObjectBuilder builder,
                                 String attributeName,
                                 String value)
        Helper method to set a string value
        Parameters:
        builder - The json object builder
        attributeName - The name of the attribute
        value - The string value
      • setStringArray

        protected void setStringArray​(javax.json.JsonObjectBuilder builder,
                                      String attributeName,
                                      String[] value)
        Helper method to set a string array
        Parameters:
        builder - The json object builder
        attributeName - The name of the attribute
        value - The string array
        Since:
        1.6.0
      • getInteger

        protected int getInteger​(String attributeName,
                                 int defaultValue)
        Helper method to get a integer value from an attribute
        Parameters:
        attributeName - The attribute name
        defaultValue - default value
        Returns:
        The integer value or the default value
      • getBoolean

        protected boolean getBoolean​(String attributeName,
                                     boolean defaultValue)
                              throws IOException
        Helper method to get a boolean value from an attribute
        Parameters:
        attributeName - The attribute name
        defaultValue - default value
        Returns:
        The boolean value or the default value
        Throws:
        IOException - If the attribute value is not of type boolean