Package com.zfabrik.components
Class Components
java.lang.Object
com.zfabrik.components.Components
Convenience wrapper around
IComponentsLookup and IComponentsManager
This class provides static access methods to most used methods in IComponentsLookup and
IComponentsManager.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IResourceHandlecomponentHandle(String componentName) Get theIResourceHandlefacet of the named component.static Collection<String>findComponents(X propertyExpression) Find all components by query expression on their properties.static <T> TgetComponentAs(String componentName, TypeRef<T> typeRef) Get a component facet by lookup throughstatic <T> TgetComponentAs(String componentName, TypeRef<T> typeRef, boolean required) Get a component facet by lookup throughstatic <T> TgetComponentAs(String componentName, Class<T> clz) Get a component facet by lookup throughstatic <T> TgetComponentAs(String componentName, Class<T> clz, boolean required) Get a component facet by lookup throughstatic PropertiesgetComponentProperties(IResourceHandle component) Get the component descriptor properties for the component supplied byIResourceHandle.static PropertiesgetComponentProperties(String componentName) Get the component descriptor properties for the component supplied by name.static <T> TgetDependencyComponentAs(IResourceHandle dependant, String name, TypeRef<T> typeRef, boolean required) Add a dependency by component name and retrieve a facet of the dependency.static <T> TgetDependencyComponentAs(IResourceHandle dependant, String name, Class<T> clz, boolean required) Add a dependency by component name and retrieve a facet of the dependency.static FileGet the resource folder of a component, if any.
-
Constructor Details
-
Components
public Components()
-
-
Method Details
-
getComponentAs
Get a component facet by lookup through
optionally requiring support of the facet.IComponentsLookup.INSTANCE.lookup(...)- Type Parameters:
T- Generic type of the facet- Parameters:
componentName- Name of the componentclz- Class of the generic typerequired- iftruethe lookup must result in a non-null result or anIllegalStateExceptionwill be thrown- Returns:
- The facet as implemented by the component
-
getComponentAs
Get a component facet by lookup through
optionally requiring support of the facet.IComponentsLookup.INSTANCE.lookup(...)- Type Parameters:
T- Generic type of the facet- Parameters:
componentName- Name of the componenttypeRef-TypeRefof the generic typerequired- iftruethe lookup must result in a non-null result or anIllegalStateExceptionwill be thrown- Returns:
- The facet as implemented by the component
-
getComponentAs
Get a component facet by lookup through
i.e. with a non-required result.getComponentAs(componentName, clz, false)- Type Parameters:
T- Generic type of the facet- Parameters:
componentName- Name of the componentclz- Class of the generic type- Returns:
- The facet as implemented by the component
-
getComponentAs
Get a component facet by lookup through
i.e. with a non-required result.getComponentAs(componentName, clz, false)- Type Parameters:
T- Generic type of the facet- Parameters:
componentName- Name of the componenttypeRef-TypeRefof the generic type- Returns:
- The facet as implemented by the component
-
componentHandle
Get theIResourceHandlefacet of the named component. Note: This lookup is generically supported by the system and always returns a non-null result.- Parameters:
componentName- Name of the component- Returns:
- The component's resource handle
-
getDependencyComponentAs
public static <T> T getDependencyComponentAs(IResourceHandle dependant, String name, Class<T> clz, boolean required) Add a dependency by component name and retrieve a facet of the dependency.- Type Parameters:
T- Generic type of the facet- Parameters:
dependant- Handle of the component that will receive the dependencyname- Name of the dependency component that will be added as a dependencyclz- Class of the generic typerequired- iftruethe lookup via the dependency must result in a non-null result or anIllegalStateExceptionwill be thrown- Returns:
- The facet as implemented by the dependency component
-
getDependencyComponentAs
public static <T> T getDependencyComponentAs(IResourceHandle dependant, String name, TypeRef<T> typeRef, boolean required) Add a dependency by component name and retrieve a facet of the dependency.- Type Parameters:
T- Generic type of the facet- Parameters:
dependant- Handle of the component that will receive the dependencyname- Name of the dependency component that will be added as a dependencytypeRef-TypeRefof the generic typerequired- iftruethe lookup via the dependency must result in a non-null result or anIllegalStateExceptionwill be thrown- Returns:
- The facet as implemented by the dependency component
-
getComponentProperties
Get the component descriptor properties for the component supplied byIResourceHandle.- Parameters:
component- Resource handle of the component to retrieve properties for- Returns:
- Properties of the supplied component
-
getComponentProperties
Get the component descriptor properties for the component supplied by name.- Parameters:
componentName- Name of the component to retrieve properties for- Returns:
- Properties of the supplied component
-
retrieve
Get the resource folder of a component, if any. See alsoIComponentsRepository.retrieve(String)- Parameters:
componentName- Name of the component- Returns:
- Resource folder as
File, ornull, if the component has no resource folder - Throws:
IOException
-
findComponents
Find all components by query expression on their properties.- Parameters:
propertyExpression- Search query for components. SeeIComponentsRepository.findComponents(X)- Returns:
- Query result
- Throws:
IOException
-