Class HierarchicalHelper
- Since:
- 1.6
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe regular expression that is used to separate properties for accessing fields on different levels of aHierarchicalWrapper. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<HierarchicalWrapper>deNormalize(List<?> input, boolean addParentObject, String... propertyNames) De-normalizes a given list of objects with a hierarchical object graph to a flattened list.static List<HierarchicalWrapper>deNormalize(List<?> input, boolean addParentObject, List<String> propertyNames) De-normalizes a given list of objects with a hierarchical object graph to a flattened list.getLevelIndexMapping(String[] propertyNames) Calculates the mapping of hierarchy levels to column indexes belonging to the level.static ObjectgetLevelObjectByProperty(HierarchicalWrapper wrapper, String propertyName) Returns the level object from the givenHierarchicalWrapperobject by the given property name.
-
Field Details
-
PROPERTY_SEPARATOR_REGEX
The regular expression that is used to separate properties for accessing fields on different levels of aHierarchicalWrapper.- See Also:
-
-
Method Details
-
deNormalize
public static List<HierarchicalWrapper> deNormalize(List<?> input, boolean addParentObject, String... propertyNames) De-normalizes a given list of objects with a hierarchical object graph to a flattened list. The flattened list therefore contains redundant data for each entry that has the same parent objects. It will createdHierarchicalWrapperobjects for this, which contain references to the original objects. Therefore property changes will be directly reflected in the hierarchical object graph.To identify the nested objects, the property names are inspected if they contain dots for hierarchical object paths. For example
parent.children.namesays that the parent has a property that is a collection (children) where each entry in the children collection is an object that has a property name. In this example there will be an entry in the flattened list for each child, where the parent is repeated in each wrapper object.- Parameters:
input- The collection of objects with a hierarchical object graph.addParentObject-trueto add row objects for parent objects that do no have object references for deeper levels,falseto have no dedicated row object for parent objects.propertyNames- The property names to access the properties in the object graph.- Returns:
- The flattened list of the hierarchical object graph.
-
deNormalize
public static List<HierarchicalWrapper> deNormalize(List<?> input, boolean addParentObject, List<String> propertyNames) De-normalizes a given list of objects with a hierarchical object graph to a flattened list. The flattened list therefore contains redundant data for each entry that has the same parent objects. It will createdHierarchicalWrapperobjects for this, which contain references to the original objects. Therefore property changes will be directly reflected in the hierarchical object graph.To identify the nested objects, the property names are inspected if they contain dots for hierarchical object paths. For example
parent.children.namesays that the parent has a property that is a collection (children) where each entry in the children collection is an object that has a property name. In this example there will be an entry in the flattened list for each child, where the parent is repeated in each wrapper object.- Parameters:
input- The collection of objects with a hierarchical object graph.addParentObject-trueto add row objects for parent objects that do no have object references for deeper levels,falseto have no dedicated row object for parent objects.propertyNames- The property names to access the properties in the object graph.- Returns:
- The flattened list of the hierarchical object graph.
-
getLevelObjectByProperty
Returns the level object from the givenHierarchicalWrapperobject by the given property name.- Parameters:
wrapper- TheHierarchicalWrapperfrom which the level object should be retrieved.propertyName- The name of the property to identify the level object from.- Returns:
- The level object from the
HierarchicalWrapperaccording to the given property name.
-
getLevelIndexMapping
Calculates the mapping of hierarchy levels to column indexes belonging to the level.- Parameters:
propertyNames- The property names to access the properties in the object graph.- Returns:
- The mapping of the level to the list of all column indexes belonging to a level.
-