Package com.landawn.abacus.util
Class u.OptionalInt
java.lang.Object
com.landawn.abacus.util.u.OptionalInt
- All Implemented Interfaces:
Immutable
,Comparable<u.OptionalInt>
- Enclosing class:
- u
@Immutable
public static final class u.OptionalInt
extends Object
implements Comparable<u.OptionalInt>, Immutable
The Class OptionalInt.
-
Method Summary
Modifier and TypeMethodDescription__()
Deprecated.to be removed in future version.boxed()
int
compareTo
(u.OptionalInt optional) static u.OptionalInt
empty()
boolean
<E extends Exception>
u.OptionalIntfilter
(Throwables.IntPredicate<E> predicate) <E extends Exception>
u.OptionalIntflatMap
(Throwables.IntFunction<u.OptionalInt, E> mapper) static u.OptionalInt
from
(OptionalInt op) int
get()
int
hashCode()
<E extends Exception>
u.OptionalIntifPresent
(Throwables.IntConsumer<E> action) <E extends Exception,
E2 extends Exception>
u.OptionalIntifPresentOrElse
(Throwables.IntConsumer<E> action, Throwables.Runnable<E2> emptyAction) If present or else.boolean
isEmpty()
boolean
<E extends Exception>
u.OptionalIntmap
(Throwables.IntUnaryOperator<E> mapper) <E extends Exception>
u.OptionalDoublemapToDouble
(Throwables.ToDoubleFunction<Integer, E> mapper) Map to double.<E extends Exception>
u.OptionalFloatmapToFloat
(Throwables.ToFloatFunction<Integer, E> mapper) Map to float.<E extends Exception>
u.OptionalLongmapToLong
(Throwables.ToLongFunction<Integer, E> mapper) Map to long.<T,
E extends Exception>
u.Optional<T>mapToNonNull
(Throwables.IntFunction<T, E> mapper) <T,
E extends Exception>
u.Nullable<T>mapToObj
(Throwables.IntFunction<T, E> mapper) Map to obj.static u.OptionalInt
of
(int value) static u.OptionalInt
ofNullable
(Integer val) <E extends Exception>
u.OptionalIntor
(Throwables.Supplier<u.OptionalInt, E> supplier) int
orElse
(int other) <E extends Exception>
intorElseGet
(Throwables.IntSupplier<E> other) Or else get.int
Or else throw.<X extends Throwable>
intorElseThrow
(Supplier<? extends X> exceptionSupplier) Or else throw.int
int
orZero()
Deprecated.useorElseZero()
stream()
To immutable list.To immutable set.toList()
toSet()
toString()
-
Method Details
-
empty
- Returns:
-
of
- Parameters:
value
-- Returns:
-
ofNullable
- Parameters:
val
-- Returns:
-
from
- Parameters:
op
-- Returns:
-
get
- Returns:
- Throws:
NoSuchElementException
- the no such element exception
-
isPresent
public boolean isPresent() -
isEmpty
public boolean isEmpty() -
ifPresent
- Type Parameters:
E
-- Parameters:
action
-- Returns:
- Throws:
E
- the e
-
ifPresentOrElse
public <E extends Exception,E2 extends Exception> u.OptionalInt ifPresentOrElse(Throwables.IntConsumer<E> action, Throwables.Runnable<E2> emptyAction) throws E, E2 If present or else.- Type Parameters:
E
-E2
-- Parameters:
action
-emptyAction
-- Returns:
- Throws:
E
- the eE2
- the e2
-
filter
- Type Parameters:
E
-- Parameters:
predicate
-- Returns:
- Throws:
E
- the e
-
map
- Type Parameters:
E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
mapToLong
public <E extends Exception> u.OptionalLong mapToLong(Throwables.ToLongFunction<Integer, E> mapper) throws EMap to long.- Type Parameters:
E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
mapToFloat
public <E extends Exception> u.OptionalFloat mapToFloat(Throwables.ToFloatFunction<Integer, E> mapper) throws EMap to float.- Type Parameters:
E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
mapToDouble
public <E extends Exception> u.OptionalDouble mapToDouble(Throwables.ToDoubleFunction<Integer, E> mapper) throws EMap to double.- Type Parameters:
E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
mapToObj
Map to obj.- Type Parameters:
T
-E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
mapToNonNull
public <T,E extends Exception> u.Optional<T> mapToNonNull(Throwables.IntFunction<T, E> mapper) throws E- Throws:
E extends Exception
-
flatMap
public <E extends Exception> u.OptionalInt flatMap(Throwables.IntFunction<u.OptionalInt, E> mapper) throws E- Type Parameters:
E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
or
public <E extends Exception> u.OptionalInt or(Throwables.Supplier<u.OptionalInt, E> supplier) throws E- Type Parameters:
E
-- Parameters:
supplier
-- Returns:
- Throws:
E
- the e
-
orZero
Deprecated.useorElseZero()
- Returns:
-
orElseZero
public int orElseZero() -
orElse
public int orElse(int other) - Parameters:
other
-- Returns:
-
orElseGet
Or else get.- Type Parameters:
E
-- Parameters:
other
-- Returns:
- Throws:
E
- the e
-
orElseThrow
Or else throw.- Returns:
- Throws:
NoSuchElementException
- the no such element exception
-
orElseThrow
Or else throw.- Type Parameters:
X
-- Parameters:
exceptionSupplier
-- Returns:
- Throws:
X
- the x
-
stream
- Returns:
-
toList
- Returns:
-
toSet
- Returns:
-
toImmutableList
To immutable list.- Returns:
-
toImmutableSet
To immutable set.- Returns:
-
boxed
- Returns:
-
toJdkOptional
- Returns:
-
__
Deprecated.to be removed in future version.- Returns:
-
compareTo
- Specified by:
compareTo
in interfaceComparable<u.OptionalInt>
- Parameters:
optional
-- Returns:
-
equals
-
hashCode
public int hashCode() -
toString
-