Class ConfigurationOptions.Builder

java.lang.Object
space.arim.dazzleconf.ConfigurationOptions.Builder
Enclosing class:
ConfigurationOptions

public static class ConfigurationOptions.Builder extends Object
Builder of ConfigurationOptions. Not thread safe
Author:
A248
  • Constructor Details

    • Builder

      public Builder()
      Creates the builder.

      Subclassing this builder is deprecated, and will be removed in a later release.
  • Method Details

    • addSerialiser

      public ConfigurationOptions.Builder addSerialiser(ValueSerialiser<?> serialiser)
      Adds the specified value serialiser to this builder
      Parameters:
      serialiser - the value serialiser
      Returns:
      this builder
      Throws:
      NullPointerException - if serialiser is null
      IllegalArgumentException - if the serialiser conflicts with an existing one
    • addSerialisers

      public ConfigurationOptions.Builder addSerialisers(ValueSerialiser<?>... serialisers)
      Adds the specified value serialisers to this builder
      Parameters:
      serialisers - the value serialisers
      Returns:
      this builder
      Throws:
      NullPointerException - if serialisers or an element in it is null
      IllegalArgumentException - if any serialiser conflicts with an existing one
    • addSerialisers

      public ConfigurationOptions.Builder addSerialisers(Collection<ValueSerialiser<?>> serialisers)
      Adds the specified value serialisers to this builder
      Parameters:
      serialisers - the value serialisers
      Returns:
      this builder
      Throws:
      NullPointerException - if serialisers or an element in it is null
      IllegalArgumentException - if any serialiser conflicts with an existing one
    • clearSerialisers

      public ConfigurationOptions.Builder clearSerialisers()
      Clears the serialisers of this builder
      Returns:
      this builder
    • addValidator

      public ConfigurationOptions.Builder addValidator(String key, ValueValidator validator)
      Adds the specified value validator to this builder
      Parameters:
      key - the config key at which to place the validator
      validator - the value validator
      Returns:
      this builder
      Throws:
      NullPointerException - if either parameter is null
    • addValidators

      public ConfigurationOptions.Builder addValidators(Map<String,​? extends ValueValidator> validators)
      Adds the specified value validators to this builder
      Parameters:
      validators - the map of keys at which the validators are placed to the validators themselves
      Returns:
      this builder
      Throws:
      NullPointerException - if the map, any key, or any value is null
    • clearValidators

      public ConfigurationOptions.Builder clearValidators()
      Clears the validators of this builder
      Returns:
      this builder
    • sorter

      Sets the ConfigurationSorter to use when writing the configuration to a stream or channel.
      By default there is no sorter (null)
      Parameters:
      sorter - the configuration sorter to use, or null for none
      Returns:
      this builder
    • setStrictParseEnums

      public ConfigurationOptions.Builder setStrictParseEnums(boolean strictParseEnums)
      Specifies whether enum values should be strictly parsed. By default this is false.

      When false, enum values are parsed ignoring case. Otherwise, they must have correct case.
      Parameters:
      strictParseEnums - whether to strictly parse enums
      Returns:
      this builder
    • setCreateSingleElementCollections

      public ConfigurationOptions.Builder setCreateSingleElementCollections(boolean createSingleElementCollections)
      Specifies whether, when a configuration value is desired as some kind of collection, but the config value is not a collection, a single element collection should be created from the value and used. By default this is false
      Parameters:
      createSingleElementCollections - whether to create single element collections
      Returns:
      this builder
    • build

      public ConfigurationOptions build()
      Builds a ValidationOptions from the contents of this builder.

      May be used repeatedly without side effects.
      Returns:
      built options
    • toString

      public String toString()
      Overrides:
      toString in class Object