Class StructureUtil
java.lang.Object
com.blackbuild.klum.ast.runtime.internal.layer3.StructureUtil
Deprecated.
Legacy static compatibility adapter for structure traversal and paths.
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Iterates through a data structure and returns all fields of the given type.Deprecated.Iterates through a data structure and returns all fields of the given type.Deprecated.Iterates through a data structure and returns all fields of the given type.static <T> Optional<T>getAncestorOfType(Object child, Class<T> type) Deprecated.Returns the ancestor of the given type for the given child object.static @NotNull StringgetFullPath(@NotNull Object leaf) Deprecated.Returns the full path of the given leaf object relative to its root element.static @NotNull StringgetFullPath(@NotNull Object leaf, @Nullable String rootPath) Deprecated.Returns the full path of the given leaf object relative to its root element.getOwnerHierarchy(Object leaf) Deprecated.Returns the owner hierarchy of the given leaf object, starting with the leaf object itself and ending with the root object.getPathOfFieldContaining(Object container, @NotNull Object child) Deprecated.Returns the name of the field of the container containing the given object.static StringgetRelativePath(Class<?> containerType, Object child) Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until an ancestor of the given type is found.static StringgetRelativePath(Class<?> containerType, Object child, String rootPath) Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until an ancestor of the given type is found.static StringgetRelativePath(Object container, Object child) Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until the container is found.static StringgetRelativePath(Object container, Object child, String rootPath) Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until the container is found.hierarchyToPath(List<Object> hierarchy) Deprecated.static StringtoDefaultFieldName(Class<?> type) Deprecated.Returns the default name for a field of the given type.static StringtoDefaultFieldName(Object object) Deprecated.Returns the default name for the type of the given object.static voidvisit(Object root, ModelVisitor visitor) Deprecated.Iterates through a data structure and invokes the given visitor for each element.static voidvisit(Object root, ModelVisitor visitor, String path) Deprecated.Iterates through a data structure and invokes the given visitor for each element.static voidvisitBuilders(InternalKlumBuilder<?> root, ModelVisitor visitor) Deprecated.Explicit construction-state traversal used by pre-materialization phases.
-
Method Details
-
toDefaultFieldName
Deprecated.Returns the default name for a field of the given type. This is the uncapitalized simple name of the type. I.e. if a class Database had a single field of type UtilSchema, then the default name of such a field would be "utilSchema".- Parameters:
type- The class- Returns:
- the uncapitalized named of the class.
-
toDefaultFieldName
Deprecated.Returns the default name for the type of the given object.- Parameters:
object- The object to determine the default name- Returns:
- The uncapitalized name of object's class
- See Also:
-
visit
Deprecated.Iterates through a data structure and invokes the given visitor for each element. The default implementation of the ModelVisitor only visits DSL objects, but this can be adjusted by overriding the shouldVisit method.The visitation only goes downwards, ignoring
OwnerandFieldType.LINKfields, and ignores object cycles.- Parameters:
root- The root object to start the visitation fromvisitor- The visitor to invoke for each element
-
visitBuilders
Deprecated.Explicit construction-state traversal used by pre-materialization phases. Sealed wrappers are filtered byBuilderVisitingPhaseAction. -
visit
Deprecated.Iterates through a data structure and invokes the given visitor for each element. Behaves likevisit(Object, ModelVisitor)but allows to specify a path representation for the root element..- Parameters:
root- The root object to start the visitation from.visitor- The visitor to invoke for each element.path- The path representation of the root element.
-
deepFind
Deprecated.Iterates through a data structure and returns all fields of the given type.- Parameters:
container- The container from which to extract the typestype- The target type to retrieve- Returns:
- a map of strings to objects
-
deepFind
public static <T> Map<String,T> deepFind(Object container, Class<T> type, List<Class<?>> ignoredTypes) Deprecated.Iterates through a data structure and returns all fields of the given type.- Parameters:
container- The container from which to extract the typestype- The target type to retrieveignoredTypes- All types in this list are completely ignored, i.e. not visited- Returns:
- a map of strings to objects
-
deepFind
public static <T> Map<String,T> deepFind(Object container, Class<T> type, List<Class<?>> ignoredTypes, String path) Deprecated.Iterates through a data structure and returns all fields of the given type.- Parameters:
container- The container from which to extract the typestype- The target type to retrieveignoredTypes- All types in this list are completely ignored, i.e. not visitedpath- The prefix to attach to the path- Returns:
- a map of strings to objects
-
getPathOfFieldContaining
public static Optional<String> getPathOfFieldContaining(Object container, @NotNull @NotNull Object child) Deprecated.Returns the name of the field of the container containing the given object. If the object is not contained in a field, returns an empty Optional. This if the object is contained in a collection or map, a gson like expression is returned ("container.map.'child-name'" or 'container.list[2]').- Parameters:
container- The container object to searchchild- The child object to look for- Returns:
- The name of the field containing the child object, or an empty Optional if the object is not contained in a field.
-
getFullPath
Deprecated.Returns the full path of the given leaf object relative to its root element. This is determined by traversing the owner fields up until no more owner fields are encountered. Note that corner cases, like an object having two different owners or having only an owner method are not handled.- Parameters:
leaf- The object whose path is to be determined- Returns:
- The full path of the object.
-
getFullPath
@NotNull public static @NotNull String getFullPath(@NotNull @NotNull Object leaf, @Nullable @Nullable String rootPath) Deprecated.Returns the full path of the given leaf object relative to its root element. This is determined by traversing the owner fields up until no more owner fields are encountered. Note that corner cases, like an object having two different owners or having only an owner method are not handled. The optional rootPath will be prepended to the path. If leaf is not a DSL object or does not have an owner, an empty string is returned, regardless of the rootPath- Parameters:
leaf- The object whose path is to be determinedrootPath- on optional root element to prepend to the path- Returns:
- The full path of the object.
-
getRelativePath
Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until the container is found. If the root is reached without finding the container, or if the ancestor structure is invalid, an IllegalArgumentException is thrown.- Parameters:
container- The container object to searchchild- The target of the path- Returns:
- The path from the container to the child object
-
getRelativePath
Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until the container is found. If the root is reached without finding the container, or if the ancestor structure is invalid, an IllegalArgumentException is thrown.- Parameters:
container- The container object to searchchild- The target of the pathrootPath- on optional root element to prepend to the path- Returns:
- The path from the container to the child object
-
getRelativePath
Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until an ancestor of the given type is found. If the root is reached without finding the container, or if the ancestor structure is invalid, an IllegalArgumentException is thrown.- Parameters:
containerType- The type of ancestor to be searched forchild- The target of the path- Returns:
- The path from the container to the child object
-
getRelativePath
Deprecated.Returns the path from the container to the child object, but searching upwards through the owner objects of each layer until an ancestor of the given type is found. If the root is reached without finding the container, or if the ancestor structure is invalid, an IllegalArgumentException is thrown.- Parameters:
containerType- The type of ancestor to be searched forchild- The target of the pathrootPath- on optional root element to prepend to the path- Returns:
- The path from the container to the child object
-
getAncestorOfType
Deprecated.Returns the ancestor of the given type for the given child object. If the child object is not a DSL object or has no ancestor of the given type, an empty optional is returned.- Type Parameters:
T- The type of ancestor to be found- Parameters:
child- The child whose ancestor is to be foundtype- The type of ancestor to be found- Returns:
- The ancestor of the given type, or an empty optional if none was found
-
hierarchyToPath
Deprecated. -
getOwnerHierarchy
Deprecated.Returns the owner hierarchy of the given leaf object, starting with the leaf object itself and ending with the root object. Throws an IllegalStateException if an object in the hierarchy contains more than one owner or if the hierarchy contains a cycle.- Parameters:
leaf- The leaf object- Returns:
- The owner hierarchy of the leaf object
-
KlumObjectSupport.of(completedObject).getStructure()for completed DSL Objects.