Package org.xnio

# Class OptionMap

java.lang.Object
org.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

Nested Classes
Modifier and Type
Class
Description
`static final class`
`OptionMap.Builder`
A builder for immutable option maps.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final OptionMap`
`EMPTY`
The empty option map.

## Method Summary

Modifier and Type
Method
Description
`static OptionMap.Builder`
`builder()`
Create a new builder.
`boolean`
`contains(Option<?> option)`
Determine whether this option map contains the given option.
`static <T> OptionMap`
`create(Option<T> option, T value)`
Create a single-valued option map.
`static <T1, T2> OptionMap`
`create(Option<T1> option1, T1 value1, Option<T2> option2, T2 value2)`
Create a two-valued option map.
`boolean`
`equals(Object other)`
Determine whether this option map is equal to another.
`boolean`
`equals(OptionMap other)`
Determine whether this option map is equal to another.
`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.
`int`
`hashCode()`
Get the hash code for this option map.
`Iterator<Option<?>>`
`iterator()`
Iterate over the options in this map.
`int`
`size()`
Get the number of options stored in this map.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Field Details

### EMPTY

public static final OptionMap EMPTY
The empty option map.

## Method Details

### 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
  `defaultValue` - the value to return if the option is not set
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

### create

public static <T> OptionMap create(Option<T> option, T value)
Create a single-valued option map.

Type Parameters:
  `T` - the option value type
Parameters:
  `option` - the option to put in the map
  `value` - the option value
Returns:
  the option map
Since:
  3.0

### create

public static <T1, T2> OptionMap create(Option<T1> option1, T1 value1, Option<T2> option2, T2 value2)
Create a two-valued option map. If both options are the same key, then only the second one is added to the map.

Type Parameters:
  `T1` - the first option value type
  `T2` - the second option value type
Parameters:
  `option1` - the first option to put in the map
  `value1` - the first option value
  `option2` - the second option to put in the map
  `value2` - the second option value
Returns:
  the option map
Since:
  3.0

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### equals

public boolean equals(Object other)
Determine whether this option map is equal to another.

Overrides:
  `equals` in class `Object`
Parameters:
  `other` - the other option map
Returns:
  `true` if they are equal, `false` otherwise

### equals

public boolean equals(OptionMap other)
Determine whether this option map is equal to another.

Parameters:
  `other` - the other option map
Returns:
  `true` if they are equal, `false` otherwise

### hashCode

public int hashCode()
Get the hash code for this option map.

Overrides:
  `hashCode` in class `Object`
Returns:
  the hash code