public final class Singular extends Object
Modifier and Type | Method and Description |
---|---|
static <V> Optional<V> |
none() |
static <V> Optional<V> |
optional(Predicate<? super V> isPresent,
V value)
Wrap an object in an
Optional , using a predicate to
determine if the value should be treated as defined. |
static <V> Optional<V> |
optional(V value)
Wrap an object or
null in an Optional . |
static <V> A<V> |
the(V value)
|
public static <V> Optional<V> optional(V value)
null
in an Optional
.V
- The type of the wrapped object.value
- The object to wrap. May be null
.Optional.Some
if value
is an object,
Optional.None
if value
is null
Optional
,
Optional.Some
,
Optional.None
public static <V> Optional<V> optional(Predicate<? super V> isPresent, V value)
Optional
, using a predicate to
determine if the value should be treated as defined.V
- The type of the wrapped object.isPresent
- A Predicate
function returning true if
the value is considered defined or 'present'. This
function must be able to handle null
.value
- The object to wrap. May be null
.Optional.Some
if value
is defined,
Optional.None
otherwise.Optional
,
Optional.Some
,
Optional.None
public static <V> A<V> the(V value)
A<V>
, for a value which is not optional,
but you want to access the API for doing operations as with an Optional
.
Use this instead of an awkward call to optional(Object)
when the value is
not in fact optional.value
- The value, may be anything or null
. NoA
.public static <V> Optional<V> none()
None
instance.Copyright © 2016. All Rights Reserved.