Class ComponentDescriptorBuilder<T>
- java.lang.Object
-
- io.streamthoughts.azkarra.runtime.components.ComponentDescriptorBuilder<T>
-
- All Implemented Interfaces:
ComponentDescriptor<T>
,Ordered
,Comparable<Ordered>
public class ComponentDescriptorBuilder<T> extends Object implements ComponentDescriptor<T>
-
-
Field Summary
-
Fields inherited from interface io.streamthoughts.azkarra.api.components.ComponentDescriptor
ORDER_BY_ORDER, ORDER_BY_VERSION
-
Fields inherited from interface io.streamthoughts.azkarra.api.components.Ordered
HIGHEST_ORDER, LOWEST_ORDER
-
-
Constructor Summary
Constructors Constructor Description ComponentDescriptorBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAliases(Set<String> aliases)
Adds new aliases to reference the described component.Set<String>
aliases()
Gets the set of aliases for this component.ComponentDescriptor<T>
build()
ClassLoader
classLoader()
Gets the classloader used to load the component.ComponentDescriptorBuilder<T>
classLoader(ClassLoader classLoader)
Sets the classLoader of the component.Optional<Condition>
condition()
Gets theCondition
that need to be fulfilled for this component to be eligible for use in the application.ComponentDescriptorBuilder<T>
condition(Condition condition)
static <T> ComponentDescriptorBuilder<T>
create()
Static helper method for creating a newComponentDescriptorBuilder
instance.static <T> ComponentDescriptorBuilder<T>
create(ComponentDescriptor<T> descriptor)
Static helper method for creating a newComponentDescriptorBuilder
instance.boolean
isEager()
Checks if the described component should be create and configure eagerly.ComponentDescriptorBuilder<T>
isEager(boolean isEager)
boolean
isPrimary()
Checks if the described component is the primary component that must be selected in the case of multiple possible implementations.ComponentDescriptorBuilder<T>
isPrimary(boolean isPrimary)
boolean
isSecondary()
Checks if the described component is a secondary component that must be de-prioritize in the case of multiple possible implementations.ComponentDescriptorBuilder<T>
isSecondary(boolean isSecondary)
boolean
isSingleton()
Checks if the described component is a singleton.ComponentDescriptorBuilder<T>
isSingleton(boolean isSingleton)
ComponentMetadata
metadata()
Gets the component metadata.ComponentDescriptorBuilder<T>
metadata(ComponentMetadata metadata)
Sets the metadata of the component.String
name()
Gets the name of the component.ComponentDescriptorBuilder<T>
name(String name)
Sets the name of the component.int
order()
ComponentDescriptorBuilder<T>
order(int order)
Sets the order of the component.Supplier<T>
supplier()
Gets the supplier used to create a new component of typeComponentDescriptor
.ComponentDescriptorBuilder<T>
supplier(Supplier<T> supplier)
Sets the supplier of the component.Class<T>
type()
Gets the type of the described component.ComponentDescriptorBuilder<T>
type(Class<T> type)
Sets the type of the component.Version
version()
Gets the version of the described component.ComponentDescriptorBuilder<T>
version(String version)
Sets the version of the component.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.streamthoughts.azkarra.api.components.ComponentDescriptor
className, isCloseable, isVersioned
-
-
-
-
Method Detail
-
create
public static <T> ComponentDescriptorBuilder<T> create()
Static helper method for creating a newComponentDescriptorBuilder
instance.- Type Parameters:
T
- the component type.- Returns:
- the new
ComponentDescriptorBuilder
instance.
-
create
public static <T> ComponentDescriptorBuilder<T> create(ComponentDescriptor<T> descriptor)
Static helper method for creating a newComponentDescriptorBuilder
instance.- Type Parameters:
T
- the component type.- Parameters:
descriptor
- theComponentDescriptor
instance.- Returns:
- the new
ComponentDescriptorBuilder
instance.
-
name
public String name()
Gets the name of the component.- Specified by:
name
in interfaceComponentDescriptor<T>
- Returns:
- the name, or
null
if the name is not set.
-
name
public ComponentDescriptorBuilder<T> name(String name)
Sets the name of the component.- Parameters:
name
- the name of the component.- Returns:
this
-
metadata
public ComponentMetadata metadata()
Gets the component metadata.- Specified by:
metadata
in interfaceComponentDescriptor<T>
- Returns:
- the
ComponentMetadata
.
-
metadata
public ComponentDescriptorBuilder<T> metadata(ComponentMetadata metadata)
Sets the metadata of the component.- Parameters:
metadata
- the metadata of the component.- Returns:
this
-
classLoader
public ClassLoader classLoader()
Gets the classloader used to load the component.- Specified by:
classLoader
in interfaceComponentDescriptor<T>
- Returns:
- the
ClassLoader
.
-
classLoader
public ComponentDescriptorBuilder<T> classLoader(ClassLoader classLoader)
Sets the classLoader of the component.- Parameters:
classLoader
- the classLoader of the component.- Returns:
this
-
addAliases
public void addAliases(Set<String> aliases)
Adds new aliases to reference the described component.- Specified by:
addAliases
in interfaceComponentDescriptor<T>
- Parameters:
aliases
- the aliases to be added.
-
aliases
public Set<String> aliases()
Gets the set of aliases for this component.- Specified by:
aliases
in interfaceComponentDescriptor<T>
- Returns:
- the aliases.
-
version
public Version version()
Gets the version of the described component.- Specified by:
version
in interfaceComponentDescriptor<T>
- Returns:
- the component version if versioned, otherwise
null
.
-
version
public ComponentDescriptorBuilder<T> version(String version)
Sets the version of the component.- Parameters:
version
- the version of the component.- Returns:
this
-
supplier
public Supplier<T> supplier()
Gets the supplier used to create a new component of typeComponentDescriptor
.- Specified by:
supplier
in interfaceComponentDescriptor<T>
- Returns:
- the
Supplier
.
-
supplier
public ComponentDescriptorBuilder<T> supplier(Supplier<T> supplier)
Sets the supplier of the component.- Parameters:
supplier
- the supplier of the component.- Returns:
this
-
type
public Class<T> type()
Gets the type of the described component.- Specified by:
type
in interfaceComponentDescriptor<T>
- Returns:
- the class of type
T
.
-
type
public ComponentDescriptorBuilder<T> type(Class<T> type)
Sets the type of the component.- Parameters:
type
- the type of the component.- Returns:
this
-
isSingleton
public ComponentDescriptorBuilder<T> isSingleton(boolean isSingleton)
-
isSingleton
public boolean isSingleton()
Checks if the described component is a singleton.- Specified by:
isSingleton
in interfaceComponentDescriptor<T>
- Returns:
true
if is singleton, otherwisefalse
.
-
isPrimary
public ComponentDescriptorBuilder<T> isPrimary(boolean isPrimary)
-
isPrimary
public boolean isPrimary()
Checks if the described component is the primary component that must be selected in the case of multiple possible implementations.- Specified by:
isPrimary
in interfaceComponentDescriptor<T>
- Returns:
true
if is primary, otherwisefalse
.- See Also:
Qualifiers.byPrimary()
-
isSecondary
public ComponentDescriptorBuilder<T> isSecondary(boolean isSecondary)
-
isSecondary
public boolean isSecondary()
Checks if the described component is a secondary component that must be de-prioritize in the case of multiple possible implementations.- Specified by:
isSecondary
in interfaceComponentDescriptor<T>
- Returns:
true
if is secondary, otherwisefalse
.- See Also:
Qualifiers.bySecondary()
,Qualifiers.excludeSecondary()
-
isEager
public boolean isEager()
Checks if the described component should be create and configure eagerly.- Specified by:
isEager
in interfaceComponentDescriptor<T>
- Returns:
true
if it s an eager component, otherwisefalse
.- See Also:
Eager
-
isEager
public ComponentDescriptorBuilder<T> isEager(boolean isEager)
-
condition
public Optional<Condition> condition()
Gets theCondition
that need to be fulfilled for this component to be eligible for use in the application.- Specified by:
condition
in interfaceComponentDescriptor<T>
- Returns:
- the
Condition
s.
-
condition
public ComponentDescriptorBuilder<T> condition(Condition condition)
-
order
public ComponentDescriptorBuilder<T> order(int order)
Sets the order of the component.- Parameters:
order
- the order of the component.- Returns:
this
-
build
public ComponentDescriptor<T> build()
-
-