XNIO API 2.1.0.CR2

org.jboss.xnio
Class OptionMap

java.lang.Object
  extended by org.jboss.xnio.OptionMap
All Implemented Interfaces:
Serializable, Iterable<Option<?>>

public final class OptionMap
extends Object
implements Iterable<Option<?>>, Serializable

An immutable map of options to option values. No null keys or values are permitted.

See Also:
Serialized Form

Nested Class Summary
static class OptionMap.Builder
          A builder for immutable option maps.
 
Field Summary
static OptionMap EMPTY
          The empty option map.
 
Method Summary
static OptionMap.Builder builder()
          Create a new builder.
 boolean contains(Option<?> option)
          Determine whether this option map contains the given option.
 boolean get(Option<Boolean> option, boolean defaultValue)
          Get a boolean value from this option map, with a specified default if the value is missing.
 int get(Option<Integer> option, int defaultValue)
          Get a int value from this option map, with a specified default if the value is missing.
 long get(Option<Long> option, long defaultValue)
          Get a long value from this option map, with a specified default if the value is missing.
<T> T
get(Option<T> option)
          Get the value of an option from this option map.
<T> T
get(Option<T> option, T defaultValue)
          Get the value of an option from this option map, with a specified default if the value is missing.
 Iterator<Option<?>> iterator()
          Iterate over the options in this map.
 int size()
          Get the number of options stored in this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final OptionMap EMPTY
The empty option map.

Method Detail

contains

public boolean contains(Option<?> option)
Determine whether this option map contains the given option.

Parameters:
option - the option to check
Returns:
true if the option is present in the option map

get

public <T> T get(Option<T> option)
Get the value of an option from this option map.

Type Parameters:
T - the type of the option
Parameters:
option - the option to get
Returns:
the option value, or null if it is not present

get

public <T> T get(Option<T> option,
                 T defaultValue)
Get the value of an option from this option map, with a specified default if the value is missing.

Type Parameters:
T - the type of the option
Parameters:
option - the option to get
Returns:
the option value, or null if it is not present

get

public boolean get(Option<Boolean> option,
                   boolean defaultValue)
Get a boolean value from this option map, with a specified default if the value is missing.

Parameters:
option - the option to get
defaultValue - the default value if the option is not present
Returns:
the result

get

public int get(Option<Integer> option,
               int defaultValue)
Get a int value from this option map, with a specified default if the value is missing.

Parameters:
option - the option to get
defaultValue - the default value if the option is not present
Returns:
the result

get

public long get(Option<Long> option,
                long defaultValue)
Get a long value from this option map, with a specified default if the value is missing.

Parameters:
option - the option to get
defaultValue - the default value if the option is not present
Returns:
the result

iterator

public Iterator<Option<?>> iterator()
Iterate over the options in this map.

Specified by:
iterator in interface Iterable<Option<?>>
Returns:
an iterator over the options

size

public int size()
Get the number of options stored in this map.

Returns:
the number of options

builder

public static OptionMap.Builder builder()
Create a new builder.

Returns:
a new builder

XNIO API 2.1.0.CR2

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