| Modifier and Type | Method and Description |
|---|---|
<R> R |
custom(Function<OptionalBoolean,R> function)
Applies custom operator on
OptionalBoolean. |
static OptionalBoolean |
empty()
Returns an empty
OptionalBoolean instance. |
boolean |
equals(Object obj) |
OptionalBoolean |
executeIfAbsent(Runnable action)
Invokes action function if value is absent.
|
OptionalBoolean |
executeIfPresent(BooleanConsumer consumer)
Invokes consumer function with the value if present.
|
OptionalBoolean |
filter(BooleanPredicate predicate)
Performs filtering on inner value if it is present.
|
OptionalBoolean |
filterNot(BooleanPredicate predicate)
Performs negated filtering on inner value if it is present.
|
boolean |
getAsBoolean()
Returns an inner value if present, otherwise throws
NoSuchElementException. |
int |
hashCode() |
void |
ifPresent(BooleanConsumer consumer)
Invokes consumer function with value if present, otherwise does nothing.
|
void |
ifPresentOrElse(BooleanConsumer consumer,
Runnable emptyAction)
If a value is present, performs the given action with the value,
otherwise performs the empty-based action.
|
boolean |
isPresent()
Checks value present.
|
OptionalBoolean |
map(BooleanPredicate mapper)
Invokes the given mapping function on inner value if present.
|
<U> Optional<U> |
mapToObj(BooleanFunction<U> mapper)
Invokes the given mapping function on inner value if present.
|
static OptionalBoolean |
of(boolean value)
Returns an
OptionalBoolean with the specified value present. |
OptionalBoolean |
or(Supplier<OptionalBoolean> supplier)
Returns current
OptionalBoolean if value is present, otherwise
returns an OptionalBoolean produced by supplier function. |
boolean |
orElse(boolean other)
Returns inner value if present, otherwise returns
other. |
boolean |
orElseGet(BooleanSupplier other)
Returns the value if present, otherwise returns value produced by supplier function.
|
<X extends Throwable> |
orElseThrow(Supplier<X> exceptionSupplier)
Returns the value if present, otherwise throws an exception provided by supplier function.
|
String |
toString() |
public static OptionalBoolean empty()
OptionalBoolean instance.OptionalBooleanpublic static OptionalBoolean of(boolean value)
OptionalBoolean with the specified value present.value - the value to be presentOptionalBoolean with the value presentpublic boolean getAsBoolean()
NoSuchElementException.OptionalBooleanNoSuchElementException - if there is no value presentisPresent()public boolean isPresent()
true if a value present, false otherwisepublic void ifPresent(BooleanConsumer consumer)
consumer - the consumer function to be executed if a value is presentNullPointerException - if value is present and consumer is nullpublic void ifPresentOrElse(BooleanConsumer consumer, Runnable emptyAction)
consumer - the consumer function to be executed, if a value is presentemptyAction - the empty-based action to be performed, if no value is presentNullPointerException - if a value is present and the given consumer function is null,
or no value is present and the given empty-based action is null.public OptionalBoolean executeIfPresent(BooleanConsumer consumer)
ifPresent, but does not breaks chainingconsumer - consumer functionOptionalBooleanifPresent(BooleanConsumer)public OptionalBoolean executeIfAbsent(Runnable action)
action - action that invokes if value absentOptionalBooleanpublic <R> R custom(Function<OptionalBoolean,R> function)
OptionalBoolean.R - the type of the resultfunction - a transforming functionNullPointerException - if function is nullpublic OptionalBoolean filter(BooleanPredicate predicate)
predicate - a predicate functionOptionalBoolean if the value is present and matches predicate,
otherwise an empty OptionalBooleanpublic OptionalBoolean filterNot(BooleanPredicate predicate)
predicate - a predicate functionOptionalBoolean if the value is present and doesn't matches predicate,
otherwise an empty OptionalBooleanpublic OptionalBoolean map(BooleanPredicate mapper)
mapper - mapping functionOptionalBoolean with transformed value if present,
otherwise an empty OptionalBooleanNullPointerException - if value is present and
mapper is nullpublic <U> Optional<U> mapToObj(BooleanFunction<U> mapper)
U - the type of result valuemapper - mapping functionOptional with transformed value if present,
otherwise an empty OptionalNullPointerException - if value is present and
mapper is nullpublic OptionalBoolean or(Supplier<OptionalBoolean> supplier)
OptionalBoolean if value is present, otherwise
returns an OptionalBoolean produced by supplier function.supplier - supplier function that produces an OptionalBoolean to be returnedOptionalBoolean if value is present, otherwise
an OptionalBoolean produced by supplier functionNullPointerException - if value is not present and
supplier or value produced by it is nullpublic boolean orElse(boolean other)
other.other - the value to be returned if there is no value presentotherpublic boolean orElseGet(BooleanSupplier other)
other - supplier function that produces value if inner value is not presentother.getAsBoolean()NullPointerException - if value is not present and other is nullpublic <X extends Throwable> boolean orElseThrow(Supplier<X> exceptionSupplier) throws X extends Throwable
X - the type of exception to be thrownexceptionSupplier - supplier function that produces an exception to be thrownX - if inner value is not presentX extends ThrowableCopyright © 2017. All rights reserved.