| java.lang.Object | |
| ↳ | com.atlassian.plugin.util.Option<A> |
A class that encapsulates null (missing) values. An Option may be either Option.Some some value or None not.
If it is a value it may be tested with the isDefined() method, but
more often it is useful to either return the value or an alternative if
not set, or map or
filter.
Mapping a None of type A to type B will simply return None of type B if performed on a None of type A. Similarly, filtering will always fail on a None.
While this class is public and abstract it does not expose a constructor as only the concrete Option.Some Some and None subclasses are meant to be used.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Filters defined options only.
| |||||||||||
Returns this
Option if it is nonempty and
applying the predicate to this option's value returns true. | |||||||||||
Returns this
Option if it is nonempty and
applying the predicate to this option's value returns true. | |||||||||||
Filter out undefined options.
| |||||||||||
Find the first option that isDefined, or if there aren't any, then none.
| |||||||||||
Apply
f to the value if defined. | |||||||||||
If this is a some value apply the some function, otherwise get the none
value.
| |||||||||||
Get the value if defined.
| |||||||||||
Get the value if defined or call the supplier and return its value if
not.
| |||||||||||
Get the value if defined, otherwise returns
other. | |||||||||||
Get the value if defined or null if not.
| |||||||||||
Apply
f to the value if defined. | |||||||||||
Factory method for None instances.
| |||||||||||
Factory method for None instances where the type token is handy.
| |||||||||||
Supplies None as required.
| |||||||||||
Factory method for
Option instances. | |||||||||||
Factory method for Option.Some Some instances.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.google.common.base.Supplier
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
Filters defined options only.
Filter out undefined options.
| options | many options that may or may not be defined |
|---|
Find the first option that isDefined, or if there aren't any, then none.
| options | an Iterable of options to search through |
|---|
Apply f to the value if defined.
Transforms to an option of the functions result type.
| f | function to apply to wrapped value |
|---|
f
If this is a some value apply the some function, otherwise get the none value.
| none | the supplier of the None type |
|---|---|
| some | the function to apply if this is a Option.Some Some |
Get the value if defined. Throw an exception otherwise.
| NoSuchElementException | if this is a none |
|---|
Get the value if defined or call the supplier and return its value if not.
Supplier
Get the value if defined, otherwise returns other.
| other | value to return if this is a none |
|---|
other
Get the value if defined or null if not.
Although the use of null is discouraged, code written to use Option must often interface with code that expects and returns nulls.
true if this is a Option.Some Some, false otherwise.
false if this is a Option.Some Some, true otherwise.
Apply f to the value if defined.
Transforms to an option of the functions result type.
| f | function to apply to wrapped value |
|---|
Factory method for None instances where the type token is handy. Allows calling in-line where the type inferencer would otherwise complain.
| type | token of the right type, unused, only here for the type inferencer |
|---|
Supplies None as required. Useful as the zero value for folds.
Factory method for Option instances.
| a | the value to hold |
|---|
Factory method for Option.Some Some instances.
| value | the value to hold |
|---|
| NullPointerException | if the parameter is null |
|---|