public static class Maybe.Absent<T> extends Maybe<T>
Maybe.Absent<T>, Maybe.AbsentNull<T>, Maybe.AbstractPresent<T>, Maybe.MaybeSupplier<T>, Maybe.Present<T>, Maybe.SoftlyPresent<T>
Modifier and Type | Method and Description |
---|---|
static <T> Maybe<T> |
castAbsent(Maybe<?> absent)
Like
Maybe.cast(Maybe) but allows any casting because that is valid for absents. |
static <T> Maybe<T> |
changeExceptionSupplier(Maybe<T> original,
<any> transform) |
static <T> Maybe<T> |
changeExceptionSupplier(Maybe<T> original,
java.lang.Class<? extends java.lang.RuntimeException> type) |
T |
get() |
java.lang.RuntimeException |
getException() |
<any> |
getExceptionSupplier() |
boolean |
isNull()
Whether the value is null, if present, or
if it was specified as absent because it was null,
e.g.
|
boolean |
isPresent() |
T |
orThrowUnwrapped()
As
Maybe.get() but if the Maybe wraps an exception
(and where Maybe.get() throws a RuntimeException indicating the caller,
caused by the exception in original processing)
this throws the original unwrapped exception
(masking the caller's location) |
absent, absent, absent, absent, absent, absentNoTrace, absentNull, absentNull, absentWithTrace, asSet, cast, equals, fromNullable, fromOptional, getException, hashCode, isAbsent, isAbsentOrNull, isPresentAndNonNull, next, of, of, of, ofAllowingNull, ofDisallowingNull, or, or, or, orNull, presentInstances, soft, softThen, toOptional, toString, transform
public boolean isNull()
Maybe
Maybe.fromNullable(Object)
.public T orThrowUnwrapped()
Maybe
Maybe.get()
but if the Maybe wraps an exception
(and where Maybe.get()
throws a RuntimeException
indicating the caller,
caused by the exception in original processing)
this throws the original unwrapped exception
(masking the caller's location)
As this masks the caller's exception, use with care, typically in a location
near the original execution, otherwise it can get confusing.
For instance someCallReturningMaybe().orThrowUnwrapped()
is a nice idiom,
but someMaybeVarReturnedEarlier.orThrowUnwrapped()
is usually a bad idea.
The benefit of this is simpler stack traces and preservation of original exception type.
orThrowUnwrapped
in class Maybe<T>
public java.lang.RuntimeException getException()
public <any> getExceptionSupplier()
public static <T> Maybe<T> changeExceptionSupplier(Maybe<T> original, java.lang.Class<? extends java.lang.RuntimeException> type)
public static <T> Maybe<T> changeExceptionSupplier(Maybe<T> original, <any> transform)
public static <T> Maybe<T> castAbsent(Maybe<?> absent)
Maybe.cast(Maybe)
but allows any casting because that is valid for absents.
Enforces that the argument really is absent.