java.lang.Object
com.blackbuild.klum.ast.runtime.internal.layer3.StructureUtil

@Deprecated(since="4.0", forRemoval=false) public class StructureUtil extends Object
Deprecated.
since 4.0; use KlumObjectSupport.of(completedObject).getStructure() for completed DSL Objects.
Legacy static compatibility adapter for structure traversal and paths.
  • Method Details

    • toDefaultFieldName

      public static String toDefaultFieldName(Class<?> type)
      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

      public static String toDefaultFieldName(Object object)
      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

      public static void visit(Object root, ModelVisitor visitor)
      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 Owner and FieldType.LINK fields, and ignores object cycles.

      Parameters:
      root - The root object to start the visitation from
      visitor - The visitor to invoke for each element
    • visitBuilders

      public static void visitBuilders(InternalKlumBuilder<?> root, ModelVisitor visitor)
      Deprecated.
      Explicit construction-state traversal used by pre-materialization phases. Sealed wrappers are filtered by BuilderVisitingPhaseAction.
    • visit

      public static void visit(Object root, ModelVisitor visitor, String path)
      Deprecated.
      Iterates through a data structure and invokes the given visitor for each element. Behaves like visit(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

      public static <T> Map<String,T> deepFind(Object container, Class<T> type)
      Deprecated.
      Iterates through a data structure and returns all fields of the given type.
      Parameters:
      container - The container from which to extract the types
      type - 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 types
      type - The target type to retrieve
      ignoredTypes - 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 types
      type - The target type to retrieve
      ignoredTypes - All types in this list are completely ignored, i.e. not visited
      path - 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 search
      child - 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

      @NotNull public static @NotNull String getFullPath(@NotNull @NotNull Object leaf)
      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 determined
      rootPath - on optional root element to prepend to the path
      Returns:
      The full path of the object.
    • getRelativePath

      public static String getRelativePath(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. 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 search
      child - The target of the path
      Returns:
      The path from the container to the child object
    • getRelativePath

      public static String getRelativePath(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. 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 search
      child - The target of the path
      rootPath - on optional root element to prepend to the path
      Returns:
      The path from the container to the child object
    • getRelativePath

      public static String getRelativePath(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. 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 for
      child - The target of the path
      Returns:
      The path from the container to the child object
    • getRelativePath

      public static String getRelativePath(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. 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 for
      child - The target of the path
      rootPath - on optional root element to prepend to the path
      Returns:
      The path from the container to the child object
    • getAncestorOfType

      public static <T> Optional<T> getAncestorOfType(Object child, Class<T> type)
      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 found
      type - The type of ancestor to be found
      Returns:
      The ancestor of the given type, or an empty optional if none was found
    • hierarchyToPath

      public static Deque<String> hierarchyToPath(List<Object> hierarchy)
      Deprecated.
    • getOwnerHierarchy

      public static List<Object> 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. 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