Class ConfigurationProperties.Builder<B extends ConfigurationProperties.Builder<B>>
- Type Parameters:
B- the type of builder
- Direct Known Subclasses:
FileConfigurationProperties.Builder
- Enclosing class:
- ConfigurationProperties
ConfigurationProperties.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()protectedBuilder(ConfigurationProperties properties) -
Method Summary
Modifier and TypeMethodDescriptionfinal BaddPostProcessor(Predicate<? super ConfigurationElement<?>> condition, UnaryOperator<?> postProcessor) Defines a post-processor for each configuration element that fulfils the given condition.final <T> BaddSerializer(Class<T> serializedType, Serializer<? super T, ?> serializer) Adds a serializer for the given type.final <T> BaddSerializerFactory(Class<T> serializedType, Function<? super SerializerContext, ? extends Serializer<T, ?>> serializerFactory) Adds a serializer factory for the given type.abstract ConfigurationPropertiesbuild()Builds aConfigurationPropertiesinstance.protected abstract BgetThis()Returns this builder.final BinputNulls(boolean inputNulls) Sets whether configuration elements, or collection elements should allow null values to bet set while deserializing the configuration.final BoutputNulls(boolean outputNulls) Sets whether configuration elements, or collection elements whose value is null should be output while serializing the configuration.final BsetFieldFilter(FieldFilter filter) Sets the field filter.final BsetNameFormatter(NameFormatter formatter) Sets the name formatter.
-
Constructor Details
-
Builder
protected Builder() -
Builder
-
-
Method Details
-
setFieldFilter
Sets the field filter. The given filter is applied in addition to and after the default filter.- Parameters:
filter- the filter- Returns:
- this builder
- Throws:
NullPointerException- iffilteris null
-
setNameFormatter
Sets the name formatter.The default value is a formatter that returns the same name that was given to it.
- Parameters:
formatter- the formatter- Returns:
- this builder
- Throws:
NullPointerException- ifformatteris null
-
addSerializer
Adds a serializer for the given type.If this library already provides a serializer for the given type (e.g.
BigInteger,LocalDate, etc.) the serializer added by this method takes precedence.If a factory is added via the
addSerializerFactory(Class, Function)method for the same type, the serializer created by that factory takes precedence.- Type Parameters:
T- the type that is serialized- Parameters:
serializedType- the class of the type that is serializedserializer- the serializer- Returns:
- this builder
- Throws:
NullPointerException- if any argument is null- See Also:
-
addSerializerFactory
public final <T> B addSerializerFactory(Class<T> serializedType, Function<? super SerializerContext, ? extends Serializer<T, ?>> serializerFactory) Adds a serializer factory for the given type.If this library already provides a serializer for the given type (e.g.
BigInteger,LocalDate, etc.) the serializer created by the factory takes precedence.If a serializer is added via the
addSerializer(Class, Serializer)method for the same type, the serializer created by the factory that was added by this method takes precedence.- Type Parameters:
T- the type that is serialized- Parameters:
serializedType- the class of the type that is serializedserializerFactory- the factory that creates a new serializer- Returns:
- this builder
- Throws:
NullPointerException- if any argument is null- See Also:
-
addPostProcessor
public final B addPostProcessor(Predicate<? super ConfigurationElement<?>> condition, UnaryOperator<?> postProcessor) Defines a post-processor for each configuration element that fulfils the given condition. Multiple post-processors are applied if an element fulfills more than one condition. The conditions are checked in the order in which they were added.NOTE: It is the developer's responsibility to ensure that the type of the configuration element matches the type the post-processor expects.
- Parameters:
condition- the condition that is checkedpostProcessor- the post-processor to be applied if the condition is true- Returns:
- this builder
- Throws:
NullPointerException- if any argument is null- See Also:
-
outputNulls
Sets whether configuration elements, or collection elements whose value is null should be output while serializing the configuration.The default value is
false.- Parameters:
outputNulls- whether to output null values- Returns:
- this builder
-
inputNulls
Sets whether configuration elements, or collection elements should allow null values to bet set while deserializing the configuration.If this option is set to false, null values read from a configuration are treated as missing.
The default value is
false.- Parameters:
inputNulls- whether to input null values- Returns:
- this builder
-
build
Builds aConfigurationPropertiesinstance.- Returns:
- newly constructed
ConfigurationProperties
-
getThis
Returns this builder.- Returns:
- this builder
-