Class Finder

java.lang.Object
com.j3d.engine.scene.find.Finder

public class Finder extends Object
The Finder class provides utility methods for searching and locating SceneObjects within the engine's hierarchical structure of Layers, Things, and GObjects.
Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • layerListSupplier

      private final Supplier<LayerList> layerListSupplier
      Supplies the LayerList containing all active layers in the engine. This allows the Finder to access the current state of layers dynamically.
  • Constructor Details

    • Finder

      public Finder(Supplier<LayerList> layerListSupplier)
      Constructs a new Finder instance.
      Parameters:
      layerListSupplier - A Supplier that provides the LayerList from which objects will be searched. This allows the Finder to always work with the most current layer data.
  • Method Details

    • getLayers

      private LayerList getLayers()
      Retrieves the current LayerList from the configured supplier.
      Returns:
      The LayerList containing all active layers.
    • nameQuery

      public static <T extends SceneObject> Query<T,String> nameQuery()
      Creates a Query that matches SceneObjects based on their name. This query compares the name of a SceneObject with a given string value.
      Type Parameters:
      T - The type of SceneObject to query.
      Returns:
      A Query instance that takes a SceneObject and a String (name) and returns true if their names are equal.
    • idQuery

      public static <T extends SceneObject> Query<T,UUID> idQuery()
      Creates a Query that matches SceneObjects based on their unique identifier (UUID). This query compares the ID of a SceneObject with a given UUID value.
      Type Parameters:
      T - The type of SceneObject to query.
      Returns:
      A Query instance that takes a SceneObject and a UUID (ID) and returns true if their IDs are equal.
    • allQuery

      public static <T extends SceneObject> Query<T,Object> allQuery()
    • instanceQuery

      public static <T extends SceneObject> Query<T,T> instanceQuery()
      Creates a Query that matches SceneObjects based on instance equality. This query uses the equals method to compare two SceneObject instances.
      Type Parameters:
      T - The type of SceneObject to query.
      Returns:
      A Query instance that takes two SceneObjects and returns true if they are considered equal by their equals method.
    • findFirst

      public <T extends SceneObject, V> FindResult findFirst(Class<T> clazz, Query<T,V> query, V value)
      Searches through all layers, things, and GObjects to find the first SceneObject of a specified type that satisfies a given query. This method traverses the entire scene graph and returns the first match found, or an empty FindResult if no object matches.
      Type Parameters:
      T - The type of SceneObject to search for.
      V - The type of the value used by the Query for comparison.
      Parameters:
      clazz - The Class object representing the type T. This is used to filter objects by their runtime type.
      query - The Query to apply to each SceneObject. It defines the condition for an object to be considered a match.
      value - The value to be used by the Query for comparison.
      Returns:
      A FindResult containing the first matching SceneObject and its hierarchical location (layer, thing, GObject indices), or an empty FindResult if no object is found.
      See Also:
    • find

      public <T extends SceneObject, V> ArrayList<FindResult> find(Class<T> clazz, Query<T,V> query, V value)
      Searches through all layers, things, and GObjects to find all SceneObjects of a specified type that satisfy a given query. This method traverses the entire scene graph and collects all matching objects.
      Type Parameters:
      T - The type of SceneObject to search for.
      V - The type of the value used by the Query for comparison.
      Parameters:
      clazz - The Class object representing the type T. This is used to filter objects by their runtime type.
      query - The Query to apply to each SceneObject. It defines the condition for an object to be considered a match.
      value - The value to be used by the Query for comparison.
      Returns:
      An ArrayList of FindResults, each containing a reference to a matching SceneObject and its hierarchical location (layer, thing, GObject indices). Returns an empty list if no objects are found.
      See Also: