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.OptionalBooleanmapToBolean
(Throwables.ToBooleanFunction<Integer, E> mapper) Map to boolean.<E extends Exception>
u.OptionalCharmapToChar
(Throwables.ToCharFunction<Integer, E> mapper) Map to char.<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.int
orElseThrow
(String errorMessage) Or else throw.int
orElseThrow
(String errorMessage, Object param) Or else throw.int
orElseThrow
(String errorMessage, Object... params) Or else throw.int
orElseThrow
(String errorMessage, Object param1, Object param2) Or else throw.int
orElseThrow
(String errorMessage, Object param1, Object param2, Object param3) 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()- Returns:
-
isEmpty
public boolean isEmpty()- Returns:
-
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
-
mapToBolean
public <E extends Exception> u.OptionalBoolean mapToBolean(Throwables.ToBooleanFunction<Integer, E> mapper) throws EMap to boolean.- Type Parameters:
E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
mapToChar
public <E extends Exception> u.OptionalChar mapToChar(Throwables.ToCharFunction<Integer, E> mapper) throws EMap to char.- 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- Type Parameters:
T
-E
-- Parameters:
mapper
-- Returns:
- Throws:
E
-
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()- Returns:
-
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.- Parameters:
errorMessage
-- Returns:
- Throws:
NoSuchElementException
- the no such element exception
-
orElseThrow
Or else throw.- Parameters:
errorMessage
-param
-- Returns:
- Throws:
NoSuchElementException
- the no such element exception
-
orElseThrow
@Beta public int orElseThrow(String errorMessage, Object param1, Object param2) throws NoSuchElementException Or else throw.- Parameters:
errorMessage
-param1
-param2
-- Returns:
- Throws:
NoSuchElementException
- the no such element exception
-
orElseThrow
@Beta public int orElseThrow(String errorMessage, Object param1, Object param2, Object param3) throws NoSuchElementException Or else throw.- Parameters:
errorMessage
-param1
-param2
-param3
-- Returns:
- Throws:
NoSuchElementException
- the no such element exception
-
orElseThrow
Or else throw.- Parameters:
errorMessage
-params
-- 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
-