Package org.xnio
Class OptionMap
java.lang.Object
org.xnio.OptionMap
- All Implemented Interfaces:
Serializable
,Iterable<Option<?>>
An immutable map of options to option values. No
null
keys or values are permitted.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A builder for immutable option maps. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic OptionMap.Builder
builder()
Create a new builder.boolean
Determine whether this option map contains the given option.static <T> OptionMap
Create a single-valued option map.static <T1,
T2> OptionMap Create a two-valued option map.boolean
Determine whether this option map is equal to another.boolean
Determine whether this option map is equal to another.boolean
Get a boolean value from this option map, with a specified default if the value is missing.int
Get a int value from this option map, with a specified default if the value is missing.long
Get a long value from this option map, with a specified default if the value is missing.<T> T
Get the value of an option from this option map.<T> T
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()
Iterate over the options in this map.int
size()
Get the number of options stored in this map.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
The empty option map.
-
-
Method Details
-
contains
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
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
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 getdefaultValue
- the value to return if the option is not set- Returns:
- the option value, or
null
if it is not present
-
get
Get a boolean value from this option map, with a specified default if the value is missing.- Parameters:
option
- the option to getdefaultValue
- the default value if the option is not present- Returns:
- the result
-
get
Get a int value from this option map, with a specified default if the value is missing.- Parameters:
option
- the option to getdefaultValue
- the default value if the option is not present- Returns:
- the result
-
get
Get a long value from this option map, with a specified default if the value is missing.- Parameters:
option
- the option to getdefaultValue
- the default value if the option is not present- Returns:
- the result
-
iterator
Iterate over the options in this map. -
size
public int size()Get the number of options stored in this map.- Returns:
- the number of options
-
builder
Create a new builder.- Returns:
- a new builder
-
create
Create a single-valued option map.- Type Parameters:
T
- the option value type- Parameters:
option
- the option to put in the mapvalue
- 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 typeT2
- the second option value type- Parameters:
option1
- the first option to put in the mapvalue1
- the first option valueoption2
- the second option to put in the mapvalue2
- the second option value- Returns:
- the option map
- Since:
- 3.0
-
toString
-
equals
Determine whether this option map is equal to another. -
equals
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.
-