Package org.refcodes.structure
Class PathMapBuilderImpl<T>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,T>
-
- org.refcodes.structure.PathMapBuilderImpl<T>
-
- Type Parameters:
T
- the generic type of the elements to be contained herein.
- All Implemented Interfaces:
java.util.Map<java.lang.String,T>
,org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.Dumpable
,org.refcodes.mixin.TypeAccessor<T>
,Clearable
,Containable
,Dictionary<java.lang.String,T>
,Dictionary.MutableDictionary<java.lang.String,T>
,Dictionary.MutableDictionary.DictionaryBuilder<java.lang.String,T,PathMap.PathMapBuilder<T>>
,Keys<K,V>
,Keys.MutableKeys<K,V>
,Keys.MutableValues<K,V>
,PathMap<T>
,PathMap.MutablePathMap<T>
,PathMap.PathMapBuilder<T>
- Direct Known Subclasses:
CanonicalMapBuilderImpl
public class PathMapBuilderImpl<T> extends java.util.HashMap<java.lang.String,T> implements PathMap.PathMapBuilder<T>
The Class PathMapBuilderImpl.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Dictionary
Dictionary.MutableDictionary<K,V>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.Dictionary.MutableDictionary
Dictionary.MutableDictionary.DictionaryBuilder<K,V,B extends Dictionary.MutableDictionary.DictionaryBuilder<K,V,B>>
-
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.structure.PathMap
PathMap.MutablePathMap<T>, PathMap.PathMapBuilder<T>
-
-
Constructor Summary
Constructors Constructor Description PathMapBuilderImpl(char aDelimiter, java.lang.Class<T> aType)
Create aPathMap.PathMapBuilder
instance using the provided path delimiter for the path declarations.PathMapBuilderImpl(java.lang.Class<T> aType)
Create an emptyPathMap.PathMapBuilder
instance using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapBuilderImpl(java.lang.Object aObj, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapBuilderImpl(java.lang.Object aObj, java.lang.Class<T> aType)
Create aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapBuilderImpl(java.lang.Object aObj, java.lang.String aFromPath, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapBuilderImpl(java.lang.Object aObj, java.lang.String aFromPath, java.lang.Class<T> aType)
Creates aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapBuilderImpl(java.lang.String aToPath, java.lang.Object aObj, char aDelimiter, java.lang.Class<T> aType)
Creates aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapBuilderImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.Class<T> aType)
Create aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapBuilderImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.String aFromPath, char aDelimiter, java.lang.Class<T> aType)
Create aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapBuilderImpl(java.lang.String aToPath, java.lang.Object aObj, java.lang.String aFromPath, java.lang.Class<T> aType)
Creates aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
for the path declarations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
compute(java.lang.String aPath, java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> remappingFunction)
T
computeIfAbsent(java.lang.String aPath, java.util.function.Function<? super java.lang.String,? extends T> mappingFunction)
T
computeIfPresent(java.lang.String aPath, java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> remappingFunction)
boolean
containsKey(java.lang.Object aPath)
Tests whether there is an element with the given key.T
get(java.lang.Object aPath)
Retrieves the element assigned to the given key.char
getDelimiter()
T
getOrDefault(java.lang.Object aPath, T publicValue)
java.lang.Class<T>
getType()
T
merge(java.lang.String aPath, T value, java.util.function.BiFunction<? super T,? super T,? extends T> remappingFunction)
T
put(java.lang.String aPath, T value)
Puts an element identified by the given key.T
putIfAbsent(java.lang.String aPath, T value)
T
remove(java.lang.Object aPath)
boolean
remove(java.lang.Object aPath, java.lang.Object value)
T
replace(java.lang.String aPath, T value)
boolean
replace(java.lang.String aPath, T oldValue, T newValue)
PathMap<T>
retrieveFrom(java.lang.String aFromPath)
PathMap<T>
retrieveTo(java.lang.String aToPath)
java.lang.Object
toDataStructure(java.lang.String aFromPath)
Similar to thePathMap.toMap(String)
method, though in case all the keys of a nestedMap
instance (applicable to the rootMap
as well) represent an array (as ofPathMap.getArray( String)
), then an array is generated where the index of each value in theMap
is represented by the number representation of theMap
's key for that value.-
Methods inherited from interface org.refcodes.structure.Containable
isEmpty, size
-
Methods inherited from class java.util.HashMap
clear, clone, containsValue, entrySet, forEach, isEmpty, keySet, putAll, replaceAll, size, values
-
Methods inherited from interface java.util.Map
clear, containsValue, entry, entrySet, equals, forEach, hashCode, isEmpty, keySet, of, of, of, of, of, of, of, of, of, of, of, ofEntries, putAll, replaceAll, size, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.structure.PathMap
children, children, children, directories, directories, directories, directories, directories, fromExternalKey, get, get, getArray, getArray, getBoolean, getBoolean, getByte, getByte, getCharacter, getCharacter, getDouble, getDouble, getFloat, getFloat, getIndexed, getIndexed, getIndexes, getIndexes, getInteger, getInteger, getLong, getLong, getRootPath, getShort, getShort, hasChildren, hasChildren, hasChildren, hasIndexed, hasIndexed, hasParentPath, isArray, isArray, isArray, isArray, isArray, isChild, isChild, isChild, isDirectory, isDirectory, isDirectory, isDirectory, isIndexed, isIndexed, isPath, isRecord, isRecord, isRecord, isRecord, isRootPath, keySet, paths, paths, paths, paths, paths, query, query, queryFrom, queryPaths, queryTo, records, records, records, records, records, retrieve, retrieveFrom, retrieveFrom, retrieveFrom, retrieveTo, retrieveTo, retrieveTo, toDataStructure, toExternalKey, toMap, toMap, toNormalizedPath, toNormalizedPath, toParentPath, toPath, toPath
-
Methods inherited from interface org.refcodes.structure.PathMap.MutablePathMap
delete, insert, insert, insert, insert, insertFrom, insertFrom, insertTo, insertTo, put, put, putArray, putArray, remove, remove, removeAll, removeAll, removeFrom, removeFrom, removeFrom, removeFrom
-
Methods inherited from interface org.refcodes.structure.PathMap.PathMapBuilder
withInsert, withInsert, withInsert, withInsert, withInsertFrom, withInsertFrom, withInsertTo, withInsertTo, withPut, withPut, withRemoveFrom
-
-
-
-
Constructor Detail
-
PathMapBuilderImpl
public PathMapBuilderImpl(java.lang.Class<T> aType)
Create an emptyPathMap.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 aPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 aPathMap.PathMapBuilder
instance containing the elements as ofPathMap.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 interfaceKeys<K,V>
- Specified by:
containsKey
in interfacejava.util.Map<java.lang.String,T>
- Overrides:
containsKey
in classjava.util.HashMap<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.
-
remove
public T remove(java.lang.Object aPath)
-
remove
public boolean remove(java.lang.Object aPath, java.lang.Object value)
-
computeIfAbsent
public T computeIfAbsent(java.lang.String aPath, java.util.function.Function<? super java.lang.String,? extends T> mappingFunction)
-
computeIfPresent
public T computeIfPresent(java.lang.String aPath, java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> remappingFunction)
-
compute
public T compute(java.lang.String aPath, java.util.function.BiFunction<? super java.lang.String,? super T,? extends T> remappingFunction)
-
merge
public T merge(java.lang.String aPath, T value, java.util.function.BiFunction<? super T,? super T,? extends T> remappingFunction)
-
retrieveTo
public PathMap<T> retrieveTo(java.lang.String aToPath)
Extracts a newPathMap
from thisPathMap
's elements with the paths relocated to the provided "to-path". Given we have a value for path "/dog/cat" in thePathMap
and we callPathMap.retrieveTo(String)
with "/animals", then the resultingPathMap
will contain the path "/animals/dog/cat" for that value.
-
retrieveFrom
public PathMap<T> retrieveFrom(java.lang.String aFromPath)
Extracts a newPathMap
from the elements of thisPathMap
found below the "from-path". The sub-paths will be the root paths for the newPathMap
. Given we have a value for path "/dog/cat" in thePathMap
and we callPathMap.retrieveFrom(String)
with "/dog", then the resultingPathMap
will contain the path "/cat" for that value.- Specified by:
retrieveFrom
in interfacePathMap<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 newPathMap
.
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
getType
public java.lang.Class<T> getType()
- Specified by:
getType
in interfaceorg.refcodes.mixin.TypeAccessor<T>
-
toDataStructure
public java.lang.Object toDataStructure(java.lang.String aFromPath)
Similar to thePathMap.toMap(String)
method, though in case all the keys of a nestedMap
instance (applicable to the rootMap
as well) represent an array (as ofPathMap.getArray( String)
), then an array is generated where the index of each value in theMap
is represented by the number representation of theMap
's key for that value. The result is a data structure consisting ofMap
instances and arrays.- Specified by:
toDataStructure
in interfacePathMap<T>
- Parameters:
aFromPath
- The path below which thePathMap
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.
-
-