Class ConfigurationProperties.Builder<B extends ConfigurationProperties.Builder<B>>

java.lang.Object
de.exlll.configlib.ConfigurationProperties.Builder<B>
Type Parameters:
B - the type of builder
Direct Known Subclasses:
FileConfigurationProperties.Builder
Enclosing class:
ConfigurationProperties

public abstract static class ConfigurationProperties.Builder<B extends ConfigurationProperties.Builder<B>> extends Object
A builder class for constructing ConfigurationProperties.
  • Constructor Details

  • Method Details

    • setFieldFilter

      public final B setFieldFilter(FieldFilter filter)
      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 - if filter is null
    • setNameFormatter

      public final B setNameFormatter(NameFormatter formatter)
      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 - if formatter is null
    • addSerializer

      public final <T> B addSerializer(Class<T> serializedType, Serializer<? super T,?> serializer)
      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 serialized
      serializer - 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 serialized
      serializerFactory - 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 checked
      postProcessor - the post-processor to be applied if the condition is true
      Returns:
      this builder
      Throws:
      NullPointerException - if any argument is null
      See Also:
    • outputNulls

      public final B outputNulls(boolean 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

      public final B inputNulls(boolean 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

      public abstract ConfigurationProperties build()
      Builds a ConfigurationProperties instance.
      Returns:
      newly constructed ConfigurationProperties
    • getThis

      protected abstract B getThis()
      Returns this builder.
      Returns:
      this builder