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 classA builder for immutable option maps. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic OptionMap.Builderbuilder()Create a new builder.booleanDetermine whether this option map contains the given option.static <T> OptionMapCreate a single-valued option map.static <T1,T2> OptionMap Create a two-valued option map.booleanDetermine whether this option map is equal to another.booleanDetermine whether this option map is equal to another.booleanGet a boolean value from this option map, with a specified default if the value is missing.intGet a int value from this option map, with a specified default if the value is missing.longGet a long value from this option map, with a specified default if the value is missing.<T> TGet the value of an option from this option map.<T> TGet the value of an option from this option map, with a specified default if the value is missing.inthashCode()Get the hash code for this option map.iterator()Iterate over the options in this map.intsize()Get the number of options stored in this map.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
trueif 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
nullif 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
nullif 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:
trueif they are equal,falseotherwise
-
hashCode
public int hashCode()Get the hash code for this option map.
-