Package com.complexible.common.base
Class Options
java.lang.Object
com.complexible.common.base.Options
- Since:
- 2.0
- Version:
- 2.2
- Author:
- Evren Sirin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OptionsCombines the given multiple options instances into one options instance.<V> booleanReturns true if this collection contains a value for the specified option.copy()Creates a mutable copy of the options instance.static Optionscreate()Creates a new empty options instance.static Optionsempty()Creates a new empty immutable Options instance.booleanvoidfromJsonString(String theJsonString) Caution: Every Option decoded by this function becomes an Option<V> VReturns the value associated with the given option or the default value of the option if there is no associated value.inthashCode()static voidInserts the given options into the existing set of options.booleanReturns the value associated with the given boolean option or the default value of the option if there is no associated value and the default value is notnullorfalseotherwise.iterator()static <V> OptionsCreates a new options instance with the given single mapping.static <V1,V2> Options Creates a new options instance with the given two mappings.static <V1,V2, V3>
OptionsCreates a new options instance with the given three mappings.<V> VRemoves any previous value associated with this option.<V> OptionsAssociate the given value with the given option overriding any previous value.Copies all of the option value mappings from the specified Options overriding any previous value.static <V> OptionsCreates an immutable option instance with the given single mapping.intsize()toString()static Optionsunmodifiable(Options options) Creates an unmodifiable, shallow copy of the options instance.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Options
public Options() -
Options
-
-
Method Details
-
iterator
-
copy
Creates a mutable copy of the options instance. Updating the copy will not affect the original options. The copy can be modified even if the original options instance may not be modifiable. -
create
Creates a new empty options instance. -
of
Creates a new options instance with the given single mapping. -
of
Creates a new options instance with the given two mappings. -
of
public static <V1,V2, Options ofV3> (Option<V1> key1, V1 value1, Option<V2> key2, V2 value2, Option<V3> key3, V3 value3) Creates a new options instance with the given three mappings. -
contains
Returns true if this collection contains a value for the specified option. -
get
Returns the value associated with the given option or the default value of the option if there is no associated value. The default value for an option might benullso there are cases this function will returnnullvalues. Must be used with care in autoboxing.- See Also:
-
is
Returns the value associated with the given boolean option or the default value of the option if there is no associated value and the default value is notnullorfalseotherwise. -
set
Associate the given value with the given option overriding any previous value. -
setAll
Copies all of the option value mappings from the specified Options overriding any previous value. .- Returns:
- a reference to this object to allow method chaining
-
remove
Removes any previous value associated with this option. -
insert
Inserts the given options into the existing set of options. Options will only be added if they do not already have a value specified in the existing options.- Parameters:
theOptions- the options to insert intotheOptionsToInsert- the new options to insert
-
combine
Combines the given multiple options instances into one options instance. If there are duplicate options in the given arguments, the value that appears in the last options instance override any previous value. -
unmodifiable
Creates an unmodifiable, shallow copy of the options instance. The unmodifiable copy cannot be updated directly but since it is a shallow copy updating the copy. If this needs to be avoidedOptions.unmodifiable(Options.copy())can be used.- Returns:
- a new options instance that will throw exceptions on modification function
-
empty
Creates a new empty immutable Options instance. -
singleton
Creates an immutable option instance with the given single mapping. -
equals
-
hashCode
public int hashCode() -
toString
-
size
public int size() -
toJsonString
-
fromJsonString
Caution: Every Option decoded by this function becomes an Option
-