@FunctionalInterface public interface OptionalIntUnaryOperator extends IntFunction<OptionalInt>
IntUnaryOperator
that returns OptionalInt
instead of the raw value. OptionalIntUnaryOperator
is typically obtained from ExceptionHandler.fromIntUnaryOperator(IntUnaryOperator)
, in which case its return value is empty when the underlying IntUnaryOperator
throws an exception. See noexception tutorial.
Modifier and Type | Method and Description |
---|---|
OptionalInt |
apply(int operand)
Variation of IntUnaryOperator.applyAsInt(int) that returns OptionalInt .
|
default IntUnaryOperator |
orElse(int result)
Converts this OptionalIntUnaryOperator to plain IntUnaryOperator using default value.
|
default IntUnaryOperator |
orElseGet(IntSupplier source)
|
OptionalInt apply(int operand)
IntUnaryOperator.applyAsInt(int)
that returns OptionalInt
. If this OptionalIntUnaryOperator
is obtained from ExceptionHandler.fromIntUnaryOperator(IntUnaryOperator)
, the OptionalInt
will be empty only if the underlying IntUnaryOperator
throws. Otherwise the returned OptionalInt
just wraps the return value of underlying IntUnaryOperator
.
apply
in interface IntFunction<OptionalInt>
operand
- see IntUnaryOperator.applyAsInt(int)
OptionalInt
typically wrapping return value of IntUnaryOperator.applyAsInt(int)
, or an empty OptionalInt
(typically signifying an exception)
ExceptionHandler.fromIntUnaryOperator(IntUnaryOperator)
, IntUnaryOperator.applyAsInt(int)
default IntUnaryOperator orElse(int result)
OptionalIntUnaryOperator
to plain IntUnaryOperator
using default value. The returned IntUnaryOperator
will unwrap present value from the OptionalInt
if possible, or return result
if the OptionalInt
is empty.
result
- default value to return instead of an empty OptionalInt
IntUnaryOperator
that either unwraps OptionalInt
or returns default value
orElseGet(IntSupplier)
, OptionalInt.orElse(int)
default IntUnaryOperator orElseGet(IntSupplier source)
OptionalIntUnaryOperator
to plain IntUnaryOperator
using fallback IntSupplier
. The returned IntUnaryOperator
will unwrap present value from the OptionalInt
if possible, or fall back to calling source
if the OptionalInt
is empty.
source
- IntSupplier
to query for fallback value when OptionalInt
is empty
IntUnaryOperator
that either unwraps OptionalInt
or falls back to source
orElse(int)
, OptionalInt.orElseGet(IntSupplier)
Copyright © 2017–2020 Robert Važan. All rights reserved.