Class DynamicModel<T>

  • All Implemented Interfaces:
    ObjectModel

    public abstract class DynamicModel<T>
    extends java.lang.Object
    implements ObjectModel
    Abstract model class for a model which supports dynamic (arbitrary) properties of type T.
    • Constructor Summary

      Constructors 
      Constructor Description
      DynamicModel​(com.google.gson.reflect.TypeToken<T> t)
      This ctor accepts a TypeToken instance that represents the type of values stored in the map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      T get​(java.lang.String key)
      Returns the value of the specified property.
      com.google.gson.reflect.TypeToken<T> getAdditionalPropertyTypeToken()
      Returns the TypeToken which describes the type of additional properties stored in the map.
      java.util.Map<java.lang.String,​T> getProperties()
      Returns a map containing the arbitrary properties set on this object.
      java.util.Set<java.lang.String> getPropertyNames()
      Returns the names of arbitrary properties set on this object.
      int hashCode()  
      T put​(java.lang.String key, T value)
      Sets an arbitrary property.
      void removeProperties()
      Removes all of the arbitrary properties set on this object.
      T removeProperty​(java.lang.String key)
      Removes the specified property from this object's map of arbitrary properties.
      void setProperties​(java.util.Map<java.lang.String,​T> properties)
      Sets the map containing the arbitrary properties set on this object.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DynamicModel

        public DynamicModel​(com.google.gson.reflect.TypeToken<T> t)
        This ctor accepts a TypeToken instance that represents the type of values stored in the map.
        Parameters:
        t - the TypeToken which represents the type of map values
    • Method Detail

      • getAdditionalPropertyTypeToken

        public com.google.gson.reflect.TypeToken<T> getAdditionalPropertyTypeToken()
        Returns the TypeToken which describes the type of additional properties stored in the map.
        Returns:
        The TypeToken which describes the map value type
      • put

        public T put​(java.lang.String key,
                     T value)
        Sets an arbitrary property.
        Parameters:
        key - the name of the property to set
        value - the value of the property to be set
        Returns:
        the previous value of the property, or null if the property was not previously set
      • get

        public T get​(java.lang.String key)
        Returns the value of the specified property.
        Parameters:
        key - the name of the property to get
        Returns:
        the value of the property, or null if the property is not set
      • setProperties

        public void setProperties​(java.util.Map<java.lang.String,​T> properties)
        Sets the map containing the arbitrary properties set on this object.
        Parameters:
        properties - a map containing arbitrary properties to set on this object
      • getProperties

        public java.util.Map<java.lang.String,​T> getProperties()
        Returns a map containing the arbitrary properties set on this object.
        Returns:
        a copy of the map containing arbitrary properties set on this object
      • getPropertyNames

        public java.util.Set<java.lang.String> getPropertyNames()
        Returns the names of arbitrary properties set on this object.
        Returns:
        a set containing the names of arbitrary properties set on this object
      • removeProperty

        public T removeProperty​(java.lang.String key)
        Removes the specified property from this object's map of arbitrary properties.
        Parameters:
        key - the name of the property to be removed
        Returns:
        the previous value of the property, or null if the property was not previously set
      • removeProperties

        public void removeProperties()
        Removes all of the arbitrary properties set on this object.
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface ObjectModel
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface ObjectModel
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface ObjectModel
        Overrides:
        toString in class java.lang.Object