public final class TypeSafeConfigurationContainer<T> extends Object
Configuration objects of the same generic type
<T> and selects the highest-precedence available ones. This is particularly
useful for source prioritization or handling multiple versions of the same
configuration object.
To create a new empty container, use the default constructor
new TypeSafeConfigurationContainer<T>(). To create a new container with preset
Configuration objects, pass them as "var-args", provided that all objects have
the same mapped bean type <T>
Use the add(Configuration<T>) method at any time to register new objects inside
the container.
To retrieve the highest-precedence Configuration bean, use the
getBean() methods.
Configuration,
ConfigurationContainer,
DataFetchStrategy| Constructor and Description |
|---|
TypeSafeConfigurationContainer(Configuration<T>... configs)
Builds a new
TypeSageConfigurationContainer with an arbitrary number of preset
Configuration objects to be registered. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Configuration<T> configuration)
Adds the specified
Configuration to this container. |
void |
clear()
Removes all of the
Configuration objects from this container. |
T |
getBean()
Returns the highest-precedence mapped bean inside this container.
|
T |
getBean(String namespace)
Returns the highest-precedence mapped bean associated with the specified namespace
inside this container.
|
boolean |
isEmpty()
Returns
true if this container contains no Configuration objects. |
long |
size()
Returns the number of
Configuration objects in this container. |
long |
size(String namespace)
Returns the number of
Configuration objects associated with the specified
namespace in this container. |
@SafeVarargs public TypeSafeConfigurationContainer(Configuration<T>... configs)
TypeSageConfigurationContainer with an arbitrary number of preset
Configuration objects to be registered.configs - an arbitrary number of Configuration objects (zero or more) to
be registered at constructor timepublic void add(Configuration<T> configuration)
Configuration to this container.configuration - the Configuration to be added to the containerpublic void clear()
Configuration objects from this container.public T getBean()
null if no
bean availablepublic T getBean(String namespace)
namespace - the namespace to querynull if no bean available in the namespacepublic long size()
Configuration objects in this container.Configuration objects in this containerpublic long size(String namespace)
Configuration objects associated with the specified
namespace in this container.namespace - the namespace to be testedConfiguration objects associated with the specified
namespacepublic boolean isEmpty()
true if this container contains no Configuration objects.true if this container contains no Configuration objectsCopyright © 2021. All rights reserved.