XNIO API 3.0.4.GA

org.xnio
Class OptionMap.Builder

java.lang.Object
  extended by org.xnio.OptionMap.Builder
Enclosing class:
OptionMap

public static final class OptionMap.Builder
extends Object

A builder for immutable option maps. Create an instance with the OptionMap.builder() method.


Method Summary
 OptionMap.Builder add(Map<?,?> map)
          Add all the entries of a map.
 OptionMap.Builder addAll(OptionMap optionMap)
          Add all entries from an existing option map to the one being built.
 OptionMap getMap()
          Build a map that reflects the current state of this builder.
<T> OptionMap.Builder
parse(Option<T> key, String stringValue)
          Set a key-value pair, parsing the value from the given string.
<T> OptionMap.Builder
parse(Option<T> key, String stringValue, ClassLoader classLoader)
          Set a key-value pair, parsing the value from the given string.
 OptionMap.Builder parseAll(Properties props, String prefix)
          Add all options from a properties file.
 OptionMap.Builder parseAll(Properties props, String prefix, ClassLoader optionClassLoader)
          Add all options from a properties file.
 OptionMap.Builder set(Option<Boolean> key, boolean value)
          Set a boolean value for a Boolean key.
 OptionMap.Builder set(Option<Integer> key, int value)
          Set an int value for an Integer key.
 OptionMap.Builder set(Option<Long> key, long value)
          Set a long value for a Long key.
<T> OptionMap.Builder
set(Option<T> key, T value)
          Set a key-value pair.
 OptionMap.Builder setSequence(Option<Sequence<Boolean>> key, boolean... values)
          Set boolean values for an Boolean sequence key.
 OptionMap.Builder setSequence(Option<Sequence<Integer>> key, int... values)
          Set int values for an Integer sequence key.
 OptionMap.Builder setSequence(Option<Sequence<Long>> key, long... values)
          Set long values for a Long sequence key.
<T> OptionMap.Builder
setSequence(Option<Sequence<T>> key, T... values)
          Set a key-value pair, where the value is a sequence type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public <T> OptionMap.Builder parse(Option<T> key,
                                   String stringValue)
Set a key-value pair, parsing the value from the given string.

Type Parameters:
T - the option type
Parameters:
key - the key
stringValue - the string value
Returns:
this builder

parse

public <T> OptionMap.Builder parse(Option<T> key,
                                   String stringValue,
                                   ClassLoader classLoader)
Set a key-value pair, parsing the value from the given string.

Type Parameters:
T - the option type
Parameters:
key - the key
stringValue - the string value
classLoader - the class loader to use for parsing the value
Returns:
this builder

parseAll

public OptionMap.Builder parseAll(Properties props,
                                  String prefix,
                                  ClassLoader optionClassLoader)
Add all options from a properties file. Finds all entries which start with a given prefix; the remainder of the property key (after the prefix) is the option name, and the value is the option value.

Parameters:
props - the properties to read
prefix - the prefix
optionClassLoader - the class loader to use to resolve option names
Returns:
this builder

parseAll

public OptionMap.Builder parseAll(Properties props,
                                  String prefix)
Add all options from a properties file. Finds all entries which start with a given prefix; the remainder of the property key (after the prefix) is the option name, and the value is the option value.

Parameters:
props - the properties to read
prefix - the prefix
Returns:
this builder

set

public <T> OptionMap.Builder set(Option<T> key,
                                 T value)
Set a key-value pair.

Type Parameters:
T - the option type
Parameters:
key - the key
value - the value
Returns:
this builder

set

public OptionMap.Builder set(Option<Integer> key,
                             int value)
Set an int value for an Integer key.

Parameters:
key - the option
value - the value
Returns:
this builder

setSequence

public OptionMap.Builder setSequence(Option<Sequence<Integer>> key,
                                     int... values)
Set int values for an Integer sequence key.

Parameters:
key - the key
values - the values
Returns:
this builder

set

public OptionMap.Builder set(Option<Long> key,
                             long value)
Set a long value for a Long key.

Parameters:
key - the option
value - the value
Returns:
this builder

setSequence

public OptionMap.Builder setSequence(Option<Sequence<Long>> key,
                                     long... values)
Set long values for a Long sequence key.

Parameters:
key - the key
values - the values
Returns:
this builder

set

public OptionMap.Builder set(Option<Boolean> key,
                             boolean value)
Set a boolean value for a Boolean key.

Parameters:
key - the option
value - the value
Returns:
this builder

setSequence

public OptionMap.Builder setSequence(Option<Sequence<Boolean>> key,
                                     boolean... values)
Set boolean values for an Boolean sequence key.

Parameters:
key - the key
values - the values
Returns:
this builder

setSequence

public <T> OptionMap.Builder setSequence(Option<Sequence<T>> key,
                                         T... values)
Set a key-value pair, where the value is a sequence type.

Type Parameters:
T - the option type
Parameters:
key - the key
values - the values
Returns:
this builder

add

public OptionMap.Builder add(Map<?,?> map)
                      throws ClassCastException
Add all the entries of a map. Any keys of the map which are not valid Options, or whose values are not valid arguments for the given Option, 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

public OptionMap.Builder addAll(OptionMap optionMap)
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

public OptionMap getMap()
Build a map that reflects the current state of this builder.

Returns:
the new immutable option map

XNIO API 3.0.4.GA

Copyright © 2010 JBoss, a division of Red Hat, Inc.