Class PathMapBuilderImpl<T>

    • Constructor Detail

      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.Class<T> aType)
        Create an empty PathMap.PathMapBuilder instance using the default path delimiter "/" (Delimiter.PATH) for the path declarations.
        Parameters:
        aType - The type of the values being referenced by the paths.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(char aDelimiter,
                                  java.lang.Class<T> aType)
        Create a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.Object aObj,
                                  java.lang.Class<T> aType)
        Create a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.String aToPath,
                                  java.lang.Object aObj,
                                  java.lang.Class<T> aType)
        Create a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.Object aObj,
                                  java.lang.String aFromPath,
                                  java.lang.Class<T> aType)
        Creates a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.String aToPath,
                                  java.lang.Object aObj,
                                  java.lang.String aFromPath,
                                  java.lang.Class<T> aType)
        Creates a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.Object aObj,
                                  char aDelimiter,
                                  java.lang.Class<T> aType)
        Creates a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.String aToPath,
                                  java.lang.Object aObj,
                                  char aDelimiter,
                                  java.lang.Class<T> aType)
        Creates a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.Object aObj,
                                  java.lang.String aFromPath,
                                  char aDelimiter,
                                  java.lang.Class<T> aType)
        Creates a PathMap.PathMapBuilder 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.
      • PathMapBuilderImpl

        public PathMapBuilderImpl​(java.lang.String aToPath,
                                  java.lang.Object aObj,
                                  java.lang.String aFromPath,
                                  char aDelimiter,
                                  java.lang.Class<T> aType)
        Create a PathMap.PathMapBuilder 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 Detail

      • containsKey

        public boolean containsKey​(java.lang.Object aPath)
        Tests whether there is an element with the given key.
        Specified by:
        containsKey in interface Keys<K,V>
        Specified by:
        containsKey in interface java.util.Map<java.lang.String,T>
        Parameters:
        aPath - The key for which to test whether there is an element.
        Returns:
        True in case there is an element for the given key.
      • get

        public T get​(java.lang.Object aPath)
        Retrieves the element assigned to the given key.
        Specified by:
        get in interface Keys<K,V>
        Specified by:
        get in interface java.util.Map<java.lang.String,T>
        Parameters:
        aPath - The key for which to get the element.
        Returns:
        The value for the key in question or null if there is none such value.
      • put

        public T put​(java.lang.String aPath,
                     T value)
        Puts an element identified by the given key.
        Specified by:
        put in interface Keys.MutableValues<K,V>
        Specified by:
        put in interface java.util.Map<java.lang.String,T>
        Parameters:
        aPath - The key which's element is to be put.
        value - the value
        Returns:
        The value being overwritten.
      • remove

        public T remove​(java.lang.Object aPath)
        Specified by:
        remove in interface java.util.Map<java.lang.String,T>
      • getOrDefault

        public T getOrDefault​(java.lang.Object aPath,
                              T publicValue)
        Specified by:
        getOrDefault in interface java.util.Map<java.lang.String,T>
      • putIfAbsent

        public T putIfAbsent​(java.lang.String aPath,
                             T value)
        Specified by:
        putIfAbsent in interface java.util.Map<java.lang.String,T>
      • remove

        public boolean remove​(java.lang.Object aPath,
                              java.lang.Object value)
        Specified by:
        remove in interface java.util.Map<java.lang.String,T>
      • replace

        public boolean replace​(java.lang.String aPath,
                               T oldValue,
                               T newValue)
        Specified by:
        replace in interface java.util.Map<java.lang.String,T>
      • replace

        public T replace​(java.lang.String aPath,
                         T value)
        Specified by:
        replace in interface java.util.Map<java.lang.String,T>
      • computeIfAbsent

        public T computeIfAbsent​(java.lang.String aPath,
                                 java.util.function.Function<? super java.lang.String,? extends T> mappingFunction)
        Specified by:
        computeIfAbsent in interface java.util.Map<java.lang.String,T>
      • computeIfPresent

        public T computeIfPresent​(java.lang.String aPath,
                                  java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> remappingFunction)
        Specified by:
        computeIfPresent in interface java.util.Map<java.lang.String,T>
      • compute

        public T compute​(java.lang.String aPath,
                         java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> remappingFunction)
        Specified by:
        compute in interface java.util.Map<java.lang.String,T>
      • merge

        public T merge​(java.lang.String aPath,
                       T value,
                       java.util.function.BiFunction<? super T,? super T,? extends T> remappingFunction)
        Specified by:
        merge in interface java.util.Map<java.lang.String,T>
      • retrieveTo

        public PathMap<T> retrieveTo​(java.lang.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.
      • retrieveFrom

        public PathMap<T> retrieveFrom​(java.lang.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.
      • getDelimiter

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

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

        public java.lang.Object toDataStructure​(java.lang.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.
      • size

        public int size​()
        Returns the number of data elements contained in the collection.
        Specified by:
        size in interface Containable
        Specified by:
        size in interface java.util.Map<java.lang.String,T>
        Returns:
        An integer representing the number of items stored in the accumulation.
      • isEmpty

        public boolean isEmpty​()
        Tests whether the accumulation is empty or not. Returns true if the accumulation is empty, else false is returned.
        Specified by:
        isEmpty in interface Containable
        Specified by:
        isEmpty in interface java.util.Map<java.lang.String,T>
        Returns:
        True if no element is contained in the accumulation - else false is returned.
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        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<K,V>
        Specified by:
        containsValue in interface java.util.Map<java.lang.String,T>
        Parameters:
        value - The value to test if a key references this value.
        Returns:
        True in case the given value is referenced by a key.
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.String,? extends T> m)
        Specified by:
        putAll in interface java.util.Map<java.lang.String,T>
      • clear

        public void clear​()
        Clears all elements contained in the implementing instance.
        Specified by:
        clear in interface Clearable
        Specified by:
        clear in interface java.util.Map<java.lang.String,T>
      • keySet

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

        public java.util.Collection<T> values​()
        Returns a Collection view of the values related to the contained keys.
        Specified by:
        values in interface Keys<K,V>
        Specified by:
        values in interface java.util.Map<java.lang.String,T>
        Returns:
        A Collection view of the values related to the contained keys.
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,T>> entrySet​()
        Specified by:
        entrySet in interface java.util.Map<java.lang.String,T>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Map<java.lang.String,T>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode​()
        Specified by:
        hashCode in interface java.util.Map<java.lang.String,T>
        Overrides:
        hashCode in class java.lang.Object
      • forEach

        public void forEach​(java.util.function.BiConsumer<? super java.lang.String,? super T> action)
        Specified by:
        forEach in interface java.util.Map<java.lang.String,T>
      • replaceAll

        public void replaceAll​(java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> function)
        Specified by:
        replaceAll in interface java.util.Map<java.lang.String,T>
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object
      • createBackingMap

        protected java.util.Map<java.lang.String,T> createBackingMap​()
        Hook for creating an individual backing Map to be used by the PathMapBuilderImpl.
        Returns:
        The backing Map to be used.