Class StructureUtility
java.lang.Object
org.refcodes.struct.StructureUtility
Utility class to avoid redundant code regarding various
ImmutablePathTable implementations.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidretrieveFrom(ImmutablePathTable<T> aFromPathTable, String aFromPath, PathTable<T> aToPathTable) Hook method for implementing theImmutablePathTable.retrieveFrom(String)method.static <T> voidretrieveTo(ImmutablePathTable<T> aFromPathTable, String aToPath, PathTable<T> aToPathTable) Hook method for implementing theImmutablePathTable.retrieveTo(String)method.static ObjecttoDataStructure(ImmutablePathTable<?> aPathTable, String aFromPath) Hook method for implementing theImmutablePathTable.toDataStructure()method.static StringtoGenericPath(ImmutablePathTable<?> aPathTable, String aPath) Normalizes the path as ofImmutablePathTable.toNormalizedPath(String)and unifies it so that a path never ends with a delimiter (DelimiterAccessor.getDelimiter()).
-
Field Details
-
SYSTEM_PROPERTY_STRUCT_KEEP_MAPS
- See Also:
-
ENVIRONMENT_VARIABLE_STRUCT_KEEP_MAPS
- See Also:
-
-
Method Details
-
retrieveFrom
public static <T> void retrieveFrom(ImmutablePathTable<T> aFromPathTable, String aFromPath, PathTable<T> aToPathTable) Hook method for implementing theImmutablePathTable.retrieveFrom(String)method.- Type Parameters:
T- The type of theImmutablePathTablethe functionality is to be applied to.- Parameters:
aFromPathTable- TheImmutablePathTablefrom which to retrieve.aFromPath- The path from where to start extracting the paths.aToPathTable- ThePathTablewhich to put the result in.
-
retrieveTo
public static <T> void retrieveTo(ImmutablePathTable<T> aFromPathTable, String aToPath, PathTable<T> aToPathTable) Hook method for implementing theImmutablePathTable.retrieveTo(String)method.- Type Parameters:
T- The type of theImmutablePathTablethe functionality is to be applied to.- Parameters:
aFromPathTable- TheImmutablePathTablefrom which to retrieve.aToPath- The path where to relocate the paths of thisImmutablePathTableto.aToPathTable- ThePathTablewhich to put the result in.
-
toDataStructure
Hook method for implementing the
ImmutablePathTable.toDataStructure()method.The
org.refcodes.runtime.SystemProperty#STRUCT_KEEP_MAPS"struct.keepMaps" as well as theorg.refcodes.runtime.EnvironmentVariable#STRUCT_KEEP_MAPS"STRUCT_KEEPMAPS" can be used to disable the conversion ofMapinstances into arrays by setting it totrue(system property beats environment variable).- Parameters:
aPathTable- TheImmutablePathTablefrom which to get the data structure.aFromPath- The path below which theImmutablePathTableto be converted into a data structure.- Returns:
- A data structure being a mixture of
Mapinstances and arrays representing the data below the given path.
-
toGenericPath
Normalizes the path as ofImmutablePathTable.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:
aPathTable- TheImmutablePathTablefor which to unify the path.aPath- The path to be unified.- Returns:
- The resulting generic path never ending with a delimiter.
-