Package io.guise.framework.component
Class Components
- java.lang.Object
-
- io.guise.framework.component.Components
-
public class Components extends java.lang.Object
Utility methods for working with components.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description Components()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <C,T extends java.util.Collection<C>>
TgetChildComponents(CompositeComponent compositeComponent, java.lang.Class<C> componentClass, T componentCollection, boolean deep, boolean below)
Retrieves all child components that are instances of the of the given class.static java.util.Collection<Component>
getComponents(Component component)
Retrieves all components, including the given component and all descendant components.static <C,T extends java.util.Collection<C>>
TgetComponents(Component component, java.lang.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.static <T extends java.util.Collection<Component>>
TgetComponents(Component component, T componentCollection)
Retrieves all components, including the given component and all descendant components.static java.util.Collection<Component>
getDescendantComponents(CompositeComponent compositeComponent)
Retrieves all descendant components.static <T extends java.util.Collection<Component>>
TgetDescendantComponents(CompositeComponent compositeComponent, T componentCollection)
Retrieves all descendant components.static com.globalmentor.net.URIPath
getNavigationPath(Component component)
Determines the navigation path of the given component, based upon theNavigationComponent
(s) in the component hierarchy.static boolean
hasChildComponent(CompositeComponent compositeComponent, Component component)
Determines if the given composite component has the given component as one of its descendants.static boolean
hasChildComponent(CompositeComponent compositeComponent, Component component, boolean deep)
Determines if the given composite component has the given component as one of its descendants.static boolean
hasComponent(Component component, Component hasComponent)
Determines if the given component is or has as a descendant the given other component.static boolean
hasComponent(Component component, Component hasComponent, boolean deep)
Determines if the given component is or has as a descendant the given other component.
-
-
-
Method Detail
-
getNavigationPath
public static com.globalmentor.net.URIPath getNavigationPath(Component component)
Determines the navigation path of the given component, based upon theNavigationComponent
(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 java.util.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:
java.lang.NullPointerException
- if the given component isnull
.
-
getComponents
public static <T extends java.util.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:
java.lang.NullPointerException
- if the given component and/or collection isnull
.
-
getComponents
public static <C,T extends java.util.Collection<C>> T getComponents(Component component, java.lang.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 totrue
, the component's child components are recursively searched if the component is a composite component. If below is set totrue
, 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 totrue
.- Returns:
- The component collection.
- Throws:
java.lang.NullPointerException
- if the given component, component class, and/or collection isnull
.
-
getDescendantComponents
public static java.util.Collection<Component> getDescendantComponents(CompositeComponent compositeComponent)
Retrieves all descendant components.- Parameters:
compositeComponent
- The component to search.- Returns:
- The collection of components.
- Throws:
java.lang.NullPointerException
- if the given component isnull
.
-
getDescendantComponents
public static <T extends java.util.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:
java.lang.NullPointerException
- if the given component and/or collection isnull
.
-
getChildComponents
public static <C,T extends java.util.Collection<C>> T getChildComponents(CompositeComponent compositeComponent, java.lang.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 totrue
, a component's child components are recursively searched if that component is a composite component. If below is set totrue
, 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 totrue
.- Returns:
- The component collection.
- Throws:
java.lang.NullPointerException
- if the given component, component class, and/or collection isnull
.
-
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:
java.lang.NullPointerException
- if one of the given components isnull
.
-
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:
java.lang.NullPointerException
- if one of the given components isnull
.
-
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:
java.lang.NullPointerException
- if the given composite component or component isnull
.
-
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:
java.lang.NullPointerException
- if the given composite component or component isnull
.
-
-