Package space.arim.dazzleconf
Class ConfigurationOptions.Builder
java.lang.Object
space.arim.dazzleconf.ConfigurationOptions.Builder
- Enclosing class:
ConfigurationOptions
Builder of
ConfigurationOptions. Not thread safe- Author:
- A248
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSerialiser(ValueSerialiser<?> serialiser) Adds the specified value serialiser to this builderaddSerialisers(Collection<ValueSerialiser<?>> serialisers) Adds the specified value serialisers to this builderaddSerialisers(ValueSerialiser<?>... serialisers) Adds the specified value serialisers to this builderaddValidator(String key, ValueValidator validator) Adds the specified value validator to this builderaddValidators(Map<String, ? extends ValueValidator> validators) Adds the specified value validators to this builderbuild()Builds aValidationOptionsfrom the contents of this builder.Clears the serialisers of this builderClears the validators of this buildersetCreateSingleElementCollections(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.setStrictParseEnums(boolean strictParseEnums) Specifies whether enum values should be strictly parsed.sorter(ConfigurationSorter sorter) Sets theConfigurationSorterto use when writing the configuration to a stream or channel.toString()
-
Constructor Details
-
Builder
public Builder()Creates the builder.
Subclassing this builder is deprecated, and will be removed in a later release.
-
-
Method Details
-
addSerialiser
Adds the specified value serialiser to this builder- Parameters:
serialiser- the value serialiser- Returns:
- this builder
- Throws:
NullPointerException- ifserialiseris nullIllegalArgumentException- if the serialiser conflicts with an existing one
-
addSerialisers
Adds the specified value serialisers to this builder- Parameters:
serialisers- the value serialisers- Returns:
- this builder
- Throws:
NullPointerException- ifserialisersor an element in it is nullIllegalArgumentException- if any serialiser conflicts with an existing one
-
addSerialisers
Adds the specified value serialisers to this builder- Parameters:
serialisers- the value serialisers- Returns:
- this builder
- Throws:
NullPointerException- ifserialisersor an element in it is nullIllegalArgumentException- if any serialiser conflicts with an existing one
-
clearSerialisers
Clears the serialisers of this builder- Returns:
- this builder
-
addValidator
Adds the specified value validator to this builder- Parameters:
key- the config key at which to place the validatorvalidator- the value validator- Returns:
- this builder
- Throws:
NullPointerException- if either parameter is null
-
addValidators
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
Clears the validators of this builder- Returns:
- this builder
-
sorter
Sets theConfigurationSorterto use when writing the configuration to a stream or channel.
By default there is no sorter (null)- Parameters:
sorter- the configuration sorter to use, ornullfor none- Returns:
- this builder
-
setStrictParseEnums
Specifies whether enum values should be strictly parsed. By default this isfalse.
Whenfalse, 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 isfalse- Parameters:
createSingleElementCollections- whether to create single element collections- Returns:
- this builder
-
build
Builds aValidationOptionsfrom the contents of this builder.
May be used repeatedly without side effects.- Returns:
- built options
-
toString
-