public class EnvBuilderBasedContext extends Object implements BuildContext
EnvironmentBuilder
to evaluate the
properties. The converter is the same as used by the
EnvironmentBuilder
.
This implementation delegates registration of instances to the provided registry. Any instance may be registered.
Constructor and Description |
---|
EnvBuilderBasedContext(EnvironmentBuilder<?> environmentBuilder,
Registry<Object> registry) |
Modifier and Type | Method and Description |
---|---|
<T> T |
evaluate(List<String> properties,
Class<T> resultClass)
Evaluate a list of properties that contains expressions.
|
Converter |
getConverter()
Access to the underlying
Converter that is used for property
value conversion. |
PropertyResolver |
getPropertyResolver()
Access to the underlying
PropertyResolver that is used for
property resolution and evaluation. |
<P,V,T extends ConfigurationValueBuilder<P,V>> |
newConfigurationValueBuilder(Function<BuildContext,T> factory)
Create a new
ConfigurationValueBuilder instance using a custom
factory. |
<P,V,T extends ConfigurationValueBuilder<P,V>> |
newConfigurationValueBuilder(P parent,
Class<V> valueClass)
Create a new
ConfigurationValueBuilder instance associated to
this BuildContext . |
<T> T |
register(T instance)
Register an instance created by a builder.
|
public EnvBuilderBasedContext(EnvironmentBuilder<?> environmentBuilder, Registry<Object> registry)
public <T> T register(T instance)
BuildContext
register
in interface BuildContext
T
- the type of the registered instance (used for fluent
chaining).instance
- the instance to registerpublic <T> T evaluate(List<String> properties, Class<T> resultClass)
BuildContext
null
value is returned then the
next property is tried and so on until one property returns a non-null
value.
If all properties return null, it returns null.
evaluate
in interface BuildContext
T
- the type of resulting valueproperties
- the list of properties to try in sequenceresultClass
- the result classpublic PropertyResolver getPropertyResolver()
BuildContext
PropertyResolver
that is used for
property resolution and evaluation.getPropertyResolver
in interface BuildContext
public Converter getConverter()
BuildContext
Converter
that is used for property
value conversion.getConverter
in interface BuildContext
public <P,V,T extends ConfigurationValueBuilder<P,V>> T newConfigurationValueBuilder(P parent, Class<V> valueClass)
BuildContext
ConfigurationValueBuilder
instance associated to
this BuildContext
.newConfigurationValueBuilder
in interface BuildContext
P
- the type of the parentV
- the type of the valueT
- the type of the ConfigurationValueBuilder
parent
- the parent instancevalueClass
- the class of the valueConfigurationValueBuilder
instancepublic <P,V,T extends ConfigurationValueBuilder<P,V>> T newConfigurationValueBuilder(Function<BuildContext,T> factory)
BuildContext
ConfigurationValueBuilder
instance using a custom
factory. The factory receives the current BuildContext
instance
in order to associate the ConfigurationValueBuilder
with this
BuildContext
.
This can be useful for creating a derived instance instead of default one.
newConfigurationValueBuilder
in interface BuildContext
P
- the type of the parentV
- the type of the valueT
- the type of the ConfigurationValueBuilder
factory
- the factory used to create the instanceConfigurationValueBuilder
instanceCopyright © 2021. All rights reserved.