Package com.landawn.abacus.util
Class Result<T,E extends Throwable>
java.lang.Object
com.landawn.abacus.util.Result<T,E>
- Type Parameters:
T
-E
-
- All Implemented Interfaces:
Immutable
- Direct Known Subclasses:
Result.R
- Author:
- Haiyang Li
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns theException
if occurred, otherwisenull
is returned.Deprecated.int
hashCode()
<E2 extends Throwable>
voidifFailure
(Throwables.Consumer<? super E, E2> actionOnFailure) ifFailureOrElse
(Throwables.Consumer<? super E, E2> actionOnFailure, Throwables.Consumer<? super T, E3> actionOnSuccess) If failure or else.<E2 extends Throwable>
voidifSuccess
(Throwables.Consumer<? super T, E2> actionOnSuccess) ifSuccessOrElse
(Throwables.Consumer<? super T, E2> actionOnSuccess, Throwables.Consumer<? super E, E3> actionOnFailure) If success or else.boolean
Checks if is failure.boolean
Checks if is success.of
(T value, E exception) Deprecated.replaced byorElseIfFailure(Object)
orElseGet
(Throwables.Supplier<? extends T, E2> otherIfErrorOccurred) Deprecated.replaced byorElseGetIfFailure(Throwables.Supplier)
orElseGetIfFailure
(Throwables.Supplier<? extends T, E2> otherIfErrorOccurred) orElseIfFailure
(T defaultValueIfErrorOccurred) Or else throw.orElseThrow
(E2 exception) orElseThrow
(Function<? super E, E2> exceptionSupplierIfErrorOccurred) Or else throw.orElseThrow
(Supplier<? extends E2> exceptionSupplier) toPair()
toString()
toTuple()
-
Method Details
-
of
- Type Parameters:
T
-E
-- Parameters:
value
-exception
-- Returns:
-
isFailure
public boolean isFailure()Checks if is failure.- Returns:
- true, if is failure
-
isSuccess
public boolean isSuccess()Checks if is success.- Returns:
- true, if is success
-
ifFailure
public <E2 extends Throwable> void ifFailure(Throwables.Consumer<? super E, E2> actionOnFailure) throws E2- Type Parameters:
E2
-- Parameters:
actionOnFailure
-- Throws:
E2
- the e2
-
ifFailureOrElse
public <E2 extends Throwable,E3 extends Throwable> void ifFailureOrElse(Throwables.Consumer<? super E, E2> actionOnFailure, Throwables.Consumer<? super T, throws E2, E3E3> actionOnSuccess) If failure or else.- Type Parameters:
E2
-E3
-- Parameters:
actionOnFailure
-actionOnSuccess
-- Throws:
E2
- the e2E3
- the e3
-
ifSuccess
public <E2 extends Throwable> void ifSuccess(Throwables.Consumer<? super T, E2> actionOnSuccess) throws E2- Type Parameters:
E2
-- Parameters:
actionOnSuccess
-- Throws:
E2
- the e2
-
ifSuccessOrElse
public <E2 extends Throwable,E3 extends Throwable> void ifSuccessOrElse(Throwables.Consumer<? super T, E2> actionOnSuccess, Throwables.Consumer<? super E, throws E2, E3E3> actionOnFailure) If success or else.- Type Parameters:
E2
-E3
-- Parameters:
actionOnSuccess
-actionOnFailure
-- Throws:
E2
- the e2E3
- the e3
-
orElse
Deprecated.replaced byorElseIfFailure(Object)
- Parameters:
defaultValueIfErrorOccurred
-- Returns:
-
orElseGet
@Deprecated public <E2 extends Throwable> T orElseGet(Throwables.Supplier<? extends T, E2> otherIfErrorOccurred) throws E2Deprecated.replaced byorElseGetIfFailure(Throwables.Supplier)
- Type Parameters:
E2
-- Parameters:
otherIfErrorOccurred
-- Returns:
- Throws:
E2
-
orElseIfFailure
- Parameters:
defaultValueIfErrorOccurred
-- Returns:
-
orElseGetIfFailure
public <E2 extends Throwable> T orElseGetIfFailure(Throwables.Supplier<? extends T, E2> otherIfErrorOccurred) throws E2- Type Parameters:
E2
-- Parameters:
otherIfErrorOccurred
-- Returns:
- Throws:
E2
-
orElseThrow
Or else throw.- Returns:
- Throws:
E
- the e
-
orElseThrow
public <E2 extends Throwable> T orElseThrow(Function<? super E, E2> exceptionSupplierIfErrorOccurred) throws E2Or else throw.- Type Parameters:
E2
-- Parameters:
exceptionSupplierIfErrorOccurred
-- Returns:
- Throws:
E2
- the e2
-
orElseThrow
- Type Parameters:
E2
-- Parameters:
exception
-- Returns:
- Throws:
E2
-
orElseThrow
- Type Parameters:
E2
-- Parameters:
exceptionSupplier
-- Returns:
- Throws:
E2
-
getException
Returns theException
if occurred, otherwisenull
is returned.- Returns:
-
getExceptionIfPresent
Deprecated.replaced bygetException
Returns theException
if occurred, otherwise an emptyOptional
is returned.- Returns:
-
toPair
- Returns:
-
toTuple
- Returns:
-
hashCode
public int hashCode() -
equals
-
toString
-
getException