Class SimpleComponentDescriptor<T>
- java.lang.Object
-
- io.streamthoughts.azkarra.api.components.SimpleComponentDescriptor<T>
-
- Type Parameters:
T
- the component-type.
- All Implemented Interfaces:
ComponentDescriptor<T>
,Ordered
,Comparable<Ordered>
- Direct Known Subclasses:
TopologyDescriptor
public class SimpleComponentDescriptor<T> extends Object implements ComponentDescriptor<T>
TheSimpleComponentDescriptor
is the base class used fro describing components.
-
-
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 Modifier Constructor Description protected
SimpleComponentDescriptor(ComponentDescriptor<T> descriptor)
Creates a newSimpleComponentDescriptor
instance from the given one.SimpleComponentDescriptor(String name, Class<T> type, ClassLoader classLoader, Supplier<T> supplier, String version, boolean isSingleton, boolean isPrimary, boolean isSecondary, boolean isEager, Condition condition, int order)
Creates a newSimpleComponentDescriptor
instance.SimpleComponentDescriptor(String name, Class<T> type, Supplier<T> supplier, boolean isSingleton)
Creates a newSimpleComponentDescriptor
instance.SimpleComponentDescriptor(String name, Class<T> type, Supplier<T> supplier, String version, boolean isSingleton)
Creates a newSimpleComponentDescriptor
instance.
-
Method Summary
All 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.ClassLoader
classLoader()
Gets the classloader used to load the component.String
className()
Gets the name of the describe component.Optional<Condition>
condition()
Gets theCondition
that need to be fulfilled for this component to be eligible for use in the application.boolean
equals(Object o)
int
hashCode()
boolean
isEager()
Checks if the described component should be create and configure eagerly.boolean
isPrimary()
Checks if the described component is the primary component that must be selected in the case of multiple possible implementations.boolean
isSecondary()
Checks if the described component is a secondary component that must be de-prioritize in the case of multiple possible implementations.boolean
isSingleton()
Checks if the described component is a singleton.ComponentMetadata
metadata()
Gets the component metadata.void
metadata(ComponentMetadata metadata)
String
name()
Gets the name of the component.int
order()
Supplier<T>
supplier()
Gets the supplier used to create a new component of typeComponentDescriptor
.String
toString()
Class<T>
type()
Gets the type of the described component.Version
version()
Gets the version of the described component.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.streamthoughts.azkarra.api.components.ComponentDescriptor
isCloseable, isVersioned
-
-
-
-
Constructor Detail
-
SimpleComponentDescriptor
public SimpleComponentDescriptor(String name, Class<T> type, Supplier<T> supplier, boolean isSingleton)
Creates a newSimpleComponentDescriptor
instance.- Parameters:
name
- the name of the component.type
- the type of the component.supplier
- the supplier of the component.isSingleton
- is the component singleton.
-
SimpleComponentDescriptor
public SimpleComponentDescriptor(String name, Class<T> type, Supplier<T> supplier, String version, boolean isSingleton)
Creates a newSimpleComponentDescriptor
instance.- Parameters:
name
- the name of the component.type
- the type of the component.supplier
- the supplier of the component.version
- the version of the component.isSingleton
- is the component singleton.
-
SimpleComponentDescriptor
public SimpleComponentDescriptor(String name, Class<T> type, ClassLoader classLoader, Supplier<T> supplier, String version, boolean isSingleton, boolean isPrimary, boolean isSecondary, boolean isEager, Condition condition, int order)
Creates a newSimpleComponentDescriptor
instance.- Parameters:
name
- the name of the component.type
- the type of the component.classLoader
- the component classloader.supplier
- the supplier of the component.version
- the version of the component.isSingleton
- is the component singleton.isPrimary
- is a primary component.isSecondary
- is a secondary component.isEager
- is the component should be eagerly initializedcondition
- is the component should be conditionally enabled.order
- the priority of the component.
-
SimpleComponentDescriptor
protected SimpleComponentDescriptor(ComponentDescriptor<T> descriptor)
Creates a newSimpleComponentDescriptor
instance from the given one.- Parameters:
descriptor
- theSimpleComponentDescriptor
to copy.
-
-
Method Detail
-
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.
-
metadata
public ComponentMetadata metadata()
Gets the component metadata.- Specified by:
metadata
in interfaceComponentDescriptor<T>
- Returns:
- the
ComponentMetadata
.
-
metadata
public void metadata(ComponentMetadata metadata)
-
classLoader
public ClassLoader classLoader()
Gets the classloader used to load the component.- Specified by:
classLoader
in interfaceComponentDescriptor<T>
- Returns:
- the
ClassLoader
.
-
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.
-
className
public String className()
Gets the name of the describe component.- Specified by:
className
in interfaceComponentDescriptor<T>
- Returns:
- the name.
-
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
.
-
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
.
-
type
public Class<T> type()
Gets the type of the described component.- Specified by:
type
in interfaceComponentDescriptor<T>
- Returns:
- the class of type
T
.
-
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 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 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
-
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.
-
-