Package io.guise.framework.component
Class Components
java.lang.Object
io.guise.framework.component.Components
Utility methods for working with components.
- Author:
- Garret Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <C,
T extends Collection<C>>
TgetChildComponents
(CompositeComponent compositeComponent, Class<C> componentClass, T componentCollection, boolean deep, boolean below) Retrieves all child components that are instances of the of the given class.static Collection<Component>
getComponents
(Component component) Retrieves all components, including the given component and all descendant components.static <C,
T extends Collection<C>>
TgetComponents
(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.static <T extends Collection<Component>>
TgetComponents
(Component component, T componentCollection) Retrieves all components, including the given component and all descendant components.static Collection<Component>
getDescendantComponents
(CompositeComponent compositeComponent) Retrieves all descendant components.static <T extends 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.
-
Constructor Details
-
Components
public Components()
-
-
Method Details
-
getComponents
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 isnull
.
-
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 isnull
.
-
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 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:
NullPointerException
- if the given component, component class, and/or collection isnull
.
-
getDescendantComponents
Retrieves all descendant components.- Parameters:
compositeComponent
- The component to search.- Returns:
- The collection of components.
- Throws:
NullPointerException
- if the given component isnull
.
-
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 isnull
.
-
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 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:
NullPointerException
- if the given component, component class, and/or collection isnull
.
-
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 isnull
.
-
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.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 isnull
.
-
hasChildComponent
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 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:
NullPointerException
- if the given composite component or component isnull
.