XNIO API 2.0.0.GA

org.jboss.xnio
Class OptionMap

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

public final class OptionMap
extends java.lang.Object
implements java.lang.Iterable<Option<?>>, java.io.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<java.lang.Boolean> option, boolean defaultValue)
          Get a boolean value from this option map, with a specified default if the value is missing.
 int get(Option<java.lang.Integer> option, int defaultValue)
          Get a int 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.
 java.util.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 boolean get(Option<java.lang.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<java.lang.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

iterator

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

Specified by:
iterator in interface java.lang.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.0.0.GA

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