Class PathMapImpl<T>

java.lang.Object
org.refcodes.struct.PathMapImpl<T>
Type Parameters:
T - the generic type
All Implemented Interfaces:
org.refcodes.mixin.AnnotatorAccessor, org.refcodes.mixin.DelimiterAccessor, org.refcodes.mixin.Dumpable, org.refcodes.mixin.EmptyAccessor, org.refcodes.mixin.TypeAccessor<T>, Containable, Dictionary<String,T>, Keys<String,T>, PathMap<T>

public class PathMapImpl<T> extends Object implements PathMap<T>
The Class PathMapImpl.
  • Constructor Details

    • PathMapImpl

      protected PathMapImpl(PathMap<T> aPathMap)
      Create a PathMap instance from the provided PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object) using the PathMap's path delimiter for the path declarations the the type of the PathMap.
      Parameters:
      aPathMap - The PathMap from which the elements are to be added.
    • PathMapImpl

      public PathMapImpl(char aDelimiter, Class<T> aType)
      Create a PathMap instance using the provided path delimiter for the path declarations.
      Parameters:
      aDelimiter - The path delimiter to be used for the path declarations.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(Object aObj, Class<T> aType)
      Create a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object) using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aObj - The object from which the elements are to be added.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(String aToPath, Object aObj, Class<T> aType)
      Create a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object) using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aToPath - The sub-path where to insert the object's introspected values to.
      aObj - The object from which the elements are to be added.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(Object aObj, String aFromPath, Class<T> aType)
      Creates a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object) using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
      Parameters:
      aObj - The object from which the elements are to be added.
      aFromPath - The path from where to start adding elements of the provided object.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(String aToPath, Object aObj, String aFromPath, Class<T> aType)
      Creates a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object) using the default path delimiter "/" (Delimiter.PATH for the path declarations.
      Parameters:
      aToPath - The sub-path where to insert the object's introspected values to.
      aObj - The object from which the elements are to be added.
      aFromPath - The path from where to start adding elements of the provided object.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(Object aObj, char aDelimiter, Class<T> aType)
      Creates a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object).
      Parameters:
      aObj - The object from which the elements are to be added.
      aDelimiter - The path delimiter to be used for the path declarations.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(String aToPath, Object aObj, char aDelimiter, Class<T> aType)
      Creates a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object).
      Parameters:
      aToPath - The sub-path where to insert the object's introspected values to.
      aObj - The object from which the elements are to be added.
      aDelimiter - The path delimiter to be used for the path declarations.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(Object aObj, String aFromPath, char aDelimiter, Class<T> aType)
      Creates a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object).
      Parameters:
      aObj - The object from which the elements are to be added.
      aFromPath - The path from where to start adding elements of the provided object.
      aDelimiter - The path delimiter to be used for the path declarations.
      aType - The type of the values being referenced by the paths.
    • PathMapImpl

      public PathMapImpl(String aToPath, Object aObj, String aFromPath, char aDelimiter, Class<T> aType)
      Create a PathMap instance containing the elements as of PathMap.MutablePathMap.insert(Object).
      Parameters:
      aToPath - The sub-path where to insert the object's introspected values to.
      aObj - The object from which the elements are to be added.
      aFromPath - The path from where to start adding elements of the provided object.
      aDelimiter - The path delimiter to be used for the path declarations.
      aType - The type of the values being referenced by the paths.
  • Method Details

    • containsKey

      public boolean containsKey(Object aKey)
      Tests whether there is an element with the given key.
      Specified by:
      containsKey in interface Keys<String,T>
      Parameters:
      aKey - The key for which to test whether there is an element.
      Returns:
      True in case there is an element for the given key.
    • containsValue

      public boolean containsValue(Object aValue)
      This method is defined for the sake of Map conformity. Tests whether the provided value has a key assigned.
      Specified by:
      containsValue in interface Keys<String,T>
      Parameters:
      aValue - The value to test if a key references this value.
      Returns:
      True in case the given value is referenced by a key.
    • get

      public T get(Object aKey)
      Retrieves the element assigned to the given key.
      Specified by:
      get in interface Keys<String,T>
      Parameters:
      aKey - The key for which to get the element.
      Returns:
      The value for the key in question or null if there is none such value.
    • keySet

      public Set<String> keySet()
      Retrieves a collection containing all the keys found in the elements of this collection.
      Specified by:
      keySet in interface Keys<String,T>
      Returns:
      A collection with key objects being the keys of all elements in this collection.
    • values

      public Collection<T> values()
      Returns a Collection view of the values related to the contained keys.
      Specified by:
      values in interface Keys<String,T>
      Returns:
      A Collection view of the values related to the contained keys.
    • size

      public int size()
      Returns the number of data elements contained in the collection.
      Specified by:
      size in interface Containable
      Returns:
      An integer representing the number of items stored in the accumulation.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.refcodes.mixin.EmptyAccessor
    • getDelimiter

      public char getDelimiter()
      Specified by:
      getDelimiter in interface org.refcodes.mixin.DelimiterAccessor
    • getAnnotator

      public char getAnnotator()
      Specified by:
      getAnnotator in interface org.refcodes.mixin.AnnotatorAccessor
    • retrieveFrom

      public PathMap<T> retrieveFrom(String aFromPath)
      Extracts a new PathMap from the elements of this PathMap found below the "from-path". The sub-paths will be the root paths for the new PathMap. Given we have a value for path "/dog/cat" in the PathMap and we call PathMap.retrieveFrom(String) with "/dog", then the resulting PathMap will contain the path "/cat" for that value.
      Specified by:
      retrieveFrom in interface PathMap<T>
      Parameters:
      aFromPath - The path from where to start extracting the paths.
      Returns:
      The PathMap with the elements below the provided path which are root elements in the new PathMap.
    • retrieveTo

      public PathMap<T> retrieveTo(String aToPath)
      Extracts a new PathMap from this PathMap's elements with the paths relocated to the provided "to-path". Given we have a value for path "/dog/cat" in the PathMap and we call PathMap.retrieveTo(String) with "/animals", then the resulting PathMap will contain the path "/animals/dog/cat" for that value.
      Specified by:
      retrieveTo in interface PathMap<T>
      Parameters:
      aToPath - The path where to relocate the paths of this PathMap to.
      Returns:
      The PathMap with the elements from the provided PathMap with accordingly relocated paths.
    • getType

      public Class<T> getType()
      Specified by:
      getType in interface org.refcodes.mixin.TypeAccessor<T>
    • toDataStructure

      public Object toDataStructure(String aFromPath)
      Similar to the PathMap.toMap(String) method, though in case all the keys of a nested Map instance (applicable to the root Map as well) represent an array (as of PathMap.getArray(String)), then an array is generated where the index of each value in the Map is represented by the number representation of the Map's key for that value. The result is a data structure consisting of Map instances and arrays.
      Specified by:
      toDataStructure in interface PathMap<T>
      Parameters:
      aFromPath - The path below which the PathMap to be converted into a data structure.
      Returns:
      A data structure being a mixture of Map instances and arrays representing the data below the given path.
    • toString

      public String toString()
      Overrides:
      toString in class Object