Option API
fpstreams.Option
Bases: Generic[T]
A container object which may or may not contain a non-null value. Replaces None checks.
empty()
classmethod
Returns an empty Option instance.
filter(predicate)
If a value is present and matches the given predicate, return an Option describing the value, otherwise return an empty Option.
flat_map(mapper)
If a value is present, apply the provided Option-bearing mapping function to it, return that result, otherwise return an empty Option.
if_present(action)
If a value is present, invokes the specified consumer with the value, otherwise does nothing.
is_empty()
Returns True if there is no value present, otherwise False.
is_present()
Returns True if there is a value present, otherwise False.
map(mapper)
If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Option describing the result.
of(value)
classmethod
Returns an Option describing the given non-null value.
of_nullable(value)
classmethod
Returns an Option describing the given value, if non-null, otherwise returns an empty Option.
or_else(other)
Return the value if present, otherwise return other.
or_else_get(supplier)
Return the value if present, otherwise invoke other and return the result of that invocation.
or_else_throw(exception_supplier)
Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.