java.lang.Object
org.refcodes.struct.StructureUtility
public class StructureUtility extends Object
Utility class to avoid redundant code regarding various
PathMap
implementations.-
Method Summary
Modifier and Type Method Description static <T> voidretrieveFrom(PathMap<T> aFromPathMap, String aFromPath, PathMap.PathMapBuilder<T> aToPathMap)Hook method for implementing thePathMap.retrieveFrom(String)method.static <T> voidretrieveTo(PathMap<T> aFromPathMap, String aToPath, PathMap.PathMapBuilder<T> aToPathMap)Hook method for implementing thePathMap.retrieveTo(String)method.static ObjecttoDataStructure(PathMap<?> aPathMap, String aFromPath)Hook method for implementing thePathMap.toDataStructure()method.static StringtoGenericPath(PathMap<?> aPathMap, String aPath)Normalizes the path as ofPathMap.toNormalizedPath(String)and unifies it so that a path never ends with a delimiter (DelimiterAccessor.getDelimiter()).
-
Method Details
-
retrieveFrom
public static <T> void retrieveFrom(PathMap<T> aFromPathMap, String aFromPath, PathMap.PathMapBuilder<T> aToPathMap)Hook method for implementing thePathMap.retrieveFrom(String)method.- Type Parameters:
T- The type of thePathMapthe functionality is to be applied to.- Parameters:
aFromPathMap- ThePathMapfrom which to retrieve.aFromPath- The path from where to start extracting the paths.aToPathMap- ThePathMap.PathMapBuilderwhich to put the result in.
-
retrieveTo
public static <T> void retrieveTo(PathMap<T> aFromPathMap, String aToPath, PathMap.PathMapBuilder<T> aToPathMap)Hook method for implementing thePathMap.retrieveTo(String)method.- Type Parameters:
T- The type of thePathMapthe functionality is to be applied to.- Parameters:
aFromPathMap- ThePathMapfrom which to retrieve.aToPath- The path where to relocate the paths of thisPathMapto.aToPathMap- ThePathMap.PathMapBuilderwhich to put the result in.
-
toDataStructure
Hook method for implementing thePathMap.toDataStructure()method. -
toGenericPath
Normalizes the path as ofPathMap.toNormalizedPath(String)and unifies it so that a path never ends with a delimiter (DelimiterAccessor.getDelimiter()). This is necessary as the root path is represented just by the delimiter, meaning that it also ends with the delimiter, though generic operations may require that a path must not end with the delimiter. This means that the root path is an emptyString.- Parameters:
aPathMap- ThePathMapfor which to unify the path.aPath- The path to be unified.- Returns:
- The resulting generic path never ending with a delimiter.
-