Class Components

java.lang.Object
io.guise.framework.component.Components

public class Components extends Object
Utility methods for working with components.
Author:
Garret Wilson
  • Constructor Details

    • Components

      public Components()
  • Method Details

    • getNavigationPath

      public static com.globalmentor.net.URIPath getNavigationPath(Component component)
      Determines the navigation path of the given component, based upon the NavigationComponent(s) in the component hierarchy.

      The navigation path is determined by finding the first NavigationComponent ancestor in the component's hierarchy.

      Parameters:
      component - The component for which the navigation path should be found.
      Returns:
      The navigation path for the given component.
    • getComponents

      public static Collection<Component> getComponents(Component component)
      Retrieves all components, including the given component and all descendant components.
      Parameters:
      component - The component to search.
      Returns:
      The collection of components.
      Throws:
      NullPointerException - if the given component is null.
    • getComponents

      public static <T extends Collection<Component>> T getComponents(Component component, T componentCollection)
      Retrieves all components, including the given component and all descendant components.
      Type Parameters:
      T - The type of the component collection.
      Parameters:
      component - The component to search.
      componentCollection - The collection into which the components will be collected.
      Returns:
      The component collection.
      Throws:
      NullPointerException - if the given component and/or collection is null.
    • getComponents

      public static <C, T extends Collection<C>> T getComponents(Component component, Class<C> componentClass, T componentCollection, boolean deep, boolean below)
      Retrieves all components, including the given component, that are instances of the of the given class. If deep is set to true, the component's child components are recursively searched if the component is a composite component. If below is set to true, the child components of any composite component that is an instance of the given class are also recursively searched.
      Type Parameters:
      C - The type of the component.
      T - The type of the component collection.
      Parameters:
      component - The component to search.
      componentClass - The type of component to retrieve.
      componentCollection - The collection into which the components will be collected.
      deep - true if the children of composite components should recursively be searched.
      below - true if the children of composite components that are instances of the given class should recursively be searched, if deep is set to true.
      Returns:
      The component collection.
      Throws:
      NullPointerException - if the given component, component class, and/or collection is null.
    • getDescendantComponents

      public static Collection<Component> getDescendantComponents(CompositeComponent compositeComponent)
      Retrieves all descendant components.
      Parameters:
      compositeComponent - The component to search.
      Returns:
      The collection of components.
      Throws:
      NullPointerException - if the given component is null.
    • getDescendantComponents

      public static <T extends Collection<Component>> T getDescendantComponents(CompositeComponent compositeComponent, T componentCollection)
      Retrieves all descendant components.
      Type Parameters:
      T - The type of the components.
      Parameters:
      compositeComponent - The component to search.
      componentCollection - The collection into which the components will be collected.
      Returns:
      The component collection.
      Throws:
      NullPointerException - if the given component and/or collection is null.
    • getChildComponents

      public static <C, T extends Collection<C>> T getChildComponents(CompositeComponent compositeComponent, Class<C> componentClass, T componentCollection, boolean deep, boolean below)
      Retrieves all child components that are instances of the of the given class. If deep is set to true, a component's child components are recursively searched if that component is a composite component. If below is set to true, the child components of any composite component that is an instance of the given class are also recursively searched.
      Type Parameters:
      T - The type of the component collection.
      C - The type of the objects from the collection.
      Parameters:
      compositeComponent - The component to search.
      componentClass - The type of component to retrieve.
      componentCollection - The collection into which the components will be collected.
      deep - true if the children of composite components should recursively be searched.
      below - true if the children of composite components that are instances of the given class should recursively be searched, if deep is set to true.
      Returns:
      The component collection.
      Throws:
      NullPointerException - if the given component, component class, and/or collection is null.
    • hasComponent

      public static boolean hasComponent(Component component, Component hasComponent)
      Determines if the given component is or has as a descendant the given other component.
      Parameters:
      component - The component to search.
      hasComponent - The component to find.
      Returns:
      true if the given component is the composite component or is a descendant of the given composite component.
      Throws:
      NullPointerException - if one of the given components is null.
    • hasComponent

      public static boolean hasComponent(Component component, Component hasComponent, boolean deep)
      Determines if the given component is or has as a descendant the given other component.
      Parameters:
      component - The component to search.
      hasComponent - The component to find.
      deep - true if the children of composite components should recursively be searched.
      Returns:
      true if the given component is the composite component or is a descendant of the given composite component.
      Throws:
      NullPointerException - if one of the given components is null.
    • hasChildComponent

      public static boolean hasChildComponent(CompositeComponent compositeComponent, Component component)
      Determines if the given composite component has the given component as one of its descendants.
      Parameters:
      compositeComponent - The component to search.
      component - The component to find.
      Returns:
      Whether the given component is a descendant of the given composite component.
      Throws:
      NullPointerException - if the given composite component or component is null.
    • hasChildComponent

      public static boolean hasChildComponent(CompositeComponent compositeComponent, Component component, boolean deep)
      Determines if the given composite component has the given component as one of its descendants.
      Parameters:
      compositeComponent - The component to search.
      component - The component to find.
      deep - true if the children of composite components should recursively be searched.
      Returns:
      Whether the given component is a descendant of the given composite component.
      Throws:
      NullPointerException - if the given composite component or component is null.