Class HiroJsonMap

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Object> fieldsMap
      All unknown keys - if any - of the JSON will be collected here
    • Constructor Summary

      Constructors 
      Constructor Description
      HiroJsonMap()
      Default constructor for Jackson
      HiroJsonMap​(java.util.Map<java.lang.String,​java.lang.Object> initialData)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFields​(java.util.Map<java.lang.String,​java.lang.Object> data)  
      java.lang.Object getField​(java.lang.String key)
      Returns any field found in this class, being inside fieldsMap or a field of a derived class.
      java.util.Map<java.lang.String,​?> getMap()
      Returns the map of fields that have NOT been assigned to fields of derived children directly.
      java.lang.Object getUnmappedField​(java.lang.String key)
      Returns a value from the fieldsMap, which are fields that have NOT been assigned to fields of derived children directly.
      void setField​(java.lang.String key, java.lang.Object value)
      Set a single field in fieldsMap.
      void setFields​(java.util.Map<java.lang.String,​java.lang.Object> data)  
      java.util.Map<java.lang.String,​java.lang.Object> toMap()
      Return a map of ALL values, including assigned fields specified in derived child classes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • fieldsMap

        protected final java.util.Map<java.lang.String,​java.lang.Object> fieldsMap
        All unknown keys - if any - of the JSON will be collected here
    • Constructor Detail

      • HiroJsonMap

        public HiroJsonMap()
        Default constructor for Jackson
      • HiroJsonMap

        public HiroJsonMap​(java.util.Map<java.lang.String,​java.lang.Object> initialData)
        Constructor
        Parameters:
        initialData - Initial data for the fieldsMap. Data will be copied via Map.putAll(Map) into fieldsMap.
    • Method Detail

      • setField

        public void setField​(java.lang.String key,
                             java.lang.Object value)
        Set a single field in fieldsMap. This is also the generic method for Jackson to set fields.
        Parameters:
        key - Key of the field.
        value - Value of the field.
      • setFields

        public void setFields​(java.util.Map<java.lang.String,​java.lang.Object> data)
        Parameters:
        data - fieldsMap will be cleared and data will be copied via Map.putAll(Map) into it.
      • addFields

        public void addFields​(java.util.Map<java.lang.String,​java.lang.Object> data)
        Parameters:
        data - Data will be copied via Map.putAll(Map) into fieldsMap.
      • getUnmappedField

        public java.lang.Object getUnmappedField​(java.lang.String key)
        Returns a value from the fieldsMap, which are fields that have NOT been assigned to fields of derived children directly.
        Parameters:
        key - The key in the fieldsMap.
        Returns:
        The value found in fieldsMap or null if not found.
      • getField

        public java.lang.Object getField​(java.lang.String key)
        Returns any field found in this class, being inside fieldsMap or a field of a derived class.

        (This is a costly operation to be called multiple times on the same object. It might be more efficient to use toMap() and get the fields from the map returned.)

        Parameters:
        key - The name of the field.
        Returns:
        The value found.
      • getMap

        public java.util.Map<java.lang.String,​?> getMap()
        Returns the map of fields that have NOT been assigned to fields of derived children directly.
        Returns:
        The map of the remaining fields.
      • toMap

        public java.util.Map<java.lang.String,​java.lang.Object> toMap()
        Return a map of ALL values, including assigned fields specified in derived child classes.
        Specified by:
        toMap in interface ToMap
        Returns:
        The map of all fields of this object.