java.lang.Object
org.refcodes.struct.PathMapImpl<T>
- Type Parameters:
T
- The type of the value elements.
- 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
,Keys<String,
,T> PathMap<T>
,Table<String,
T>
The
PathMapImpl
class implements the PathMap
interface and
provides a hook createBackingMap()
method which may be overridden
for providing another Map
type as backing map than the default one.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.AnnotatorAccessor
org.refcodes.mixin.AnnotatorAccessor.AnnotatorBuilder<B extends org.refcodes.mixin.AnnotatorAccessor.AnnotatorBuilder<B>>, org.refcodes.mixin.AnnotatorAccessor.AnnotatorMutator, org.refcodes.mixin.AnnotatorAccessor.AnnotatorProperty
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.mixin.EmptyAccessor
org.refcodes.mixin.EmptyAccessor.EmptyMutator, org.refcodes.mixin.EmptyAccessor.EmptyProperty
Nested classes/interfaces inherited from interface org.refcodes.struct.Keys
Keys.MutableKeys<K,
V>, Keys.MutableValues<K, V> Nested classes/interfaces inherited from interface org.refcodes.struct.PathMap
PathMap.MutablePathMap<T>, PathMap.PathMapBuilder<T>
Nested classes/interfaces inherited from interface org.refcodes.struct.Table
Table.TableDictionary<K,
V> Nested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor
org.refcodes.mixin.TypeAccessor.TypeBuilder<T extends Object,
B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T, B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T extends Object>, org.refcodes.mixin.TypeAccessor.TypeProperty<T extends Object> -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionPathMapImpl
(char aDelimiter, Class<T> aType) Create aPathMap
instance using the provided path delimiter for the path declarations.PathMapImpl
(Object aObj, char aDelimiter, Class<T> aType) Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl
(Object aObj, Class<T> aType) Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapImpl
(Object aObj, String aFromPath, char aDelimiter, Class<T> aType) Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl
(Object aObj, String aFromPath, Class<T> aType) Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.PathMapImpl
(String aToPath, Object aObj, char aDelimiter, Class<T> aType) Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.PathMapImpl
(String aToPath, Object aObj, Class<T> aType) Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
) for the path declarations.Create aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
.Creates aPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using the default path delimiter "/" (Delimiter.PATH
for the path declarations.protected
PathMapImpl
(PathMap<T> aPathMap) Create aPathMap
instance from the providedPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using thePathMap
's path delimiter for the path declarations the the type of thePathMap
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object aKey) Tests whether there is an element with the given key.boolean
containsValue
(Object aValue) This method is defined for the sake ofMap
conformity.Hook for creating an individual backingMap
to be used by thePathMapImpl
type (defaults toLinkedHashMap
).Retrieves the element assigned to the given key.char
char
getType()
boolean
isEmpty()
keySet()
Retrieves a collection containing all the keys found in the elements of this collection.retrieveFrom
(String aFromPath) retrieveTo
(String aToPath) int
size()
Returns the number of data elements contained in the collection.toDataStructure
(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.values()
Returns aCollection
view of the values related to the contained keys.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.mixin.Dumpable
toDump, toDump
Methods inherited from interface org.refcodes.struct.PathMap
children, children, children, children, children, children, containsKey, containsKey, containsKey, dirs, dirs, dirs, dirs, dirs, dirs, findPaths, fromExternalPath, get, get, get, getArray, getArray, getArray, getArray, getArray, getArray, getArrayIndexes, getArrayIndexes, getArrayIndexes, getArrayIndexes, getArrayIndexes, getArrayOr, getArrayOr, getArrayOr, getArrayOr, getArrayOr, getArrayOr, getDir, getDir, getDir, getDir, getDir, getDirAt, getDirAt, getDirAt, getDirAt, getDirAt, getDirAt, getDirIndexes, getDirIndexes, getDirIndexes, getDirIndexes, getDirIndexes, getDirIndexes, getDirs, getDirs, getDirs, getDirs, getDirs, getRootPath, getValueAt, getValueAt, getValueAt, getValueAt, getValueAt, getValueAt, hasChildren, hasChildren, hasChildren, hasChildren, hasChildren, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasDirAt, hasParentPath, hasPath, hasPath, hasPath, hasPath, hasPath, hasSubDirs, hasSubDirs, hasSubDirs, hasSubDirs, hasValue, hasValue, hasValue, hasValue, hasValue, hasValueAt, hasValueAt, hasValueAt, hasValueAt, hasValueAt, hasValueAt, hasValueAt, hasValueAt, isArray, isArray, isArray, isArray, isArray, isArray, isChild, isChild, isChild, isChild, isDir, isDir, isDir, isDir, isDir, isEqualTo, isIndexDir, isIndexDir, isIndexDir, isIndexDir, isIndexDir, isLeaf, isLeaf, isLeaf, isLeaf, isLeaf, isRootPath, keySet, keySet, keySet, keySet, keySet, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastArrayIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, lastDirIndex, leaves, leaves, leaves, leaves, leaves, leaves, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextArrayIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, nextDirIndex, paths, paths, paths, paths, paths, paths, query, query, query, query, query, queryBetween, queryBetween, queryBetween, queryBetween, queryBetween, queryBetween, queryFrom, queryFrom, queryFrom, queryFrom, queryFrom, queryFrom, queryPaths, queryPaths, queryPaths, queryPaths, queryPaths, queryPaths, queryTo, queryTo, queryTo, queryTo, queryTo, queryTo, retrieveBetween, retrieveBetween, retrieveBetween, retrieveBetween, retrieveBetween, retrieveFrom, retrieveFrom, retrieveFrom, retrieveFrom, retrieveTo, retrieveTo, retrieveTo, retrieveTo, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, sortedKeys, toDataStructure, toExternalPath, toInstance, toInstance, toLeaf, toMap, toMap, toNormalizedPath, toParentPath, toPath, toPath, toPath, toPath, toPathElements, toPathList, toPathStack, toPrintable, toPropertyPath, toType, toType, toType, toType, toType, toType, toType, toType
-
Constructor Details
-
PathMapImpl
Create aPathMap
instance from the providedPathMap
instance containing the elements as ofPathMap.MutablePathMap.insert(Object)
using thePathMap
's path delimiter for the path declarations the the type of thePathMap
.- Parameters:
aPathMap
- ThePathMap
from which the elements are to be added.
-
PathMapImpl
Create aPathMap
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
Create aPathMap
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.
-
PathMapImpl
Create aPathMap
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.
-
PathMapImpl
Creates aPathMap
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.
-
PathMapImpl
Creates aPathMap
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.
-
PathMapImpl
Creates aPathMap
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.
-
PathMapImpl
Creates aPathMap
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.
-
PathMapImpl
Creates aPathMap
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.
-
PathMapImpl
Create aPathMap
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 Details
-
containsKey
Tests whether there is an element with the given key.- Specified by:
containsKey
in interfaceKeys<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
This method is defined for the sake ofMap
conformity. Tests whether the provided value has a key assigned.- Specified by:
containsValue
in interfaceKeys<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
Retrieves the element assigned to the given key. -
keySet
Retrieves a collection containing all the keys found in the elements of this collection. -
values
Returns aCollection
view of the values related to the contained keys.- Specified by:
values
in interfaceKeys<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 interfaceContainable
- Returns:
- An integer representing the number of items stored in the accumulation.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceorg.refcodes.mixin.EmptyAccessor
-
getDelimiter
public char getDelimiter()- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
getAnnotator
public char getAnnotator()- Specified by:
getAnnotator
in interfaceorg.refcodes.mixin.AnnotatorAccessor
-
retrieveFrom
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
.
-
retrieveTo
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. -
getType
- Specified by:
getType
in interfaceorg.refcodes.mixin.TypeAccessor<T>
-
toDataStructure
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.
-
createBackingMap
Hook for creating an individual backingMap
to be used by thePathMapImpl
type (defaults toLinkedHashMap
).- Returns:
- The backing
Map
to be used.
-