Package org.xnio
Class OptionMap.Builder
java.lang.Object
org.xnio.OptionMap.Builder
- Enclosing class:
- OptionMap
A builder for immutable option maps. Create an instance with the
OptionMap.builder()
method.-
Method Summary
Modifier and TypeMethodDescriptionAdd all the entries of a map.Add all entries from an existing option map to the one being built.getMap()
Build a map that reflects the current state of this builder.Set a key-value pair, parsing the value from the given string.parse
(Option<T> key, String stringValue, ClassLoader classLoader) Set a key-value pair, parsing the value from the given string.parseAll
(Properties props, String prefix) Add all options from a properties file.parseAll
(Properties props, String prefix, ClassLoader optionClassLoader) Add all options from a properties file.Set a boolean value for a Boolean key.Set an int value for an Integer key.Set a long value for a Long key.Set a key-value pair.setSequence
(Option<Sequence<Boolean>> key, boolean... values) Set boolean values for an Boolean sequence key.setSequence
(Option<Sequence<Integer>> key, int... values) Set int values for an Integer sequence key.setSequence
(Option<Sequence<Long>> key, long... values) Set long values for a Long sequence key.setSequence
(Option<Sequence<T>> key, T... values) Set a key-value pair, where the value is a sequence type.
-
Method Details
-
parse
Set a key-value pair, parsing the value from the given string.- Type Parameters:
T
- the option type- Parameters:
key
- the keystringValue
- the string value- Returns:
- this builder
-
parse
Set a key-value pair, parsing the value from the given string.- Type Parameters:
T
- the option type- Parameters:
key
- the keystringValue
- the string valueclassLoader
- the class loader to use for parsing the value- Returns:
- this builder
-
parseAll
Add all options from a properties file. Finds all entries which start with a given prefix followed by '.'; the remainder of the property key (after the prefix) is the option name, and the value is the option value.If the prefix does not end with '.' character, a '.' will be appended to it before parsing.
- Parameters:
props
- the properties to readprefix
- the prefixoptionClassLoader
- the class loader to use to resolve option names- Returns:
- this builder
-
parseAll
Add all options from a properties file. Finds all entries which start with a given prefix followed by '.'; the remainder of the property key (after the prefix) is the option name, and the value is the option value.If the prefix does not end with '.' character, a '.' will be appended to it before parsing.
- Parameters:
props
- the properties to readprefix
- the prefix- Returns:
- this builder
-
set
Set a key-value pair.- Type Parameters:
T
- the option type- Parameters:
key
- the keyvalue
- the value- Returns:
- this builder
-
set
Set an int value for an Integer key.- Parameters:
key
- the optionvalue
- the value- Returns:
- this builder
-
setSequence
Set int values for an Integer sequence key.- Parameters:
key
- the keyvalues
- the values- Returns:
- this builder
-
set
Set a long value for a Long key.- Parameters:
key
- the optionvalue
- the value- Returns:
- this builder
-
setSequence
Set long values for a Long sequence key.- Parameters:
key
- the keyvalues
- the values- Returns:
- this builder
-
set
Set a boolean value for a Boolean key.- Parameters:
key
- the optionvalue
- the value- Returns:
- this builder
-
setSequence
Set boolean values for an Boolean sequence key.- Parameters:
key
- the keyvalues
- the values- Returns:
- this builder
-
setSequence
Set a key-value pair, where the value is a sequence type.- Type Parameters:
T
- the option type- Parameters:
key
- the keyvalues
- the values- Returns:
- this builder
-
add
Add all the entries of a map. Any keys of the map which are not validOption
s, or whose values are not valid arguments for the givenOption
, will cause an exception to be thrown. Any keys which occur more than once in this builder will be overwritten with the last occurring value.- Parameters:
map
- the map- Returns:
- this builder
- Throws:
ClassCastException
- if any entries of the map are not valid option-value pairs
-
addAll
Add all entries from an existing option map to the one being built. Any keys which occur more than once in this builder will be overwritten with the last occurring value.- Parameters:
optionMap
- the original option map- Returns:
- this builder
-
getMap
Build a map that reflects the current state of this builder.- Returns:
- the new immutable option map
-