- java.lang.Object
-
- org.junit.platform.commons.function.Try<V>
-
- org.junit.platform.commons.function.Try.Failure<V>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.junit.platform.commons.function.Try
Try.Transformer<S,T>
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Exception
cause
-
Constructor Summary
Constructors Constructor Description Failure(java.lang.Exception cause)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <U> Try<U>
andThen(java.util.function.Function<V,Try<U>> function)
If thisTry
is a success, apply the supplied function to its value and return the resultingTry
; if thisTry
is a failure, do nothing.<U> Try<U>
andThenTry(Try.Transformer<V,U> transformer)
If thisTry
is a success, apply the supplied transformer to its value and return a new successful or failedTry
depending on the transformer's outcome; if thisTry
is a failure, do nothing.boolean
equals(java.lang.Object that)
V
get()
If thisTry
is a success, get the contained value; if thisTry
is a failure, throw the contained exception.<E extends java.lang.Exception>
VgetOrThrow(java.util.function.Function<? super java.lang.Exception,E> exceptionTransformer)
If thisTry
is a success, get the contained value; if thisTry
is a failure, call the suppliedFunction
with the contained exception and throw the resultingException
.int
hashCode()
Try<V>
ifFailure(java.util.function.Consumer<java.lang.Exception> causeConsumer)
If thisTry
is a failure, call the suppliedConsumer
with the contained exception; otherwise, do nothing.Try<V>
ifSuccess(java.util.function.Consumer<V> valueConsumer)
If thisTry
is a success, call the suppliedConsumer
with the contained value; otherwise, do nothing.Try<V>
orElse(java.util.function.Supplier<Try<V>> supplier)
If thisTry
is a failure, call the supplied supplier and return the resultingTry
; if thisTry
is a success, do nothing.Try<V>
orElseTry(java.util.concurrent.Callable<V> action)
If thisTry
is a failure, call the supplied action and return a new successful or failedTry
depending on the action's outcome; if thisTry
is a success, do nothing.java.util.Optional<V>
toOptional()
If thisTry
is a failure, return an emptyOptional
; if thisTry
is a success, wrap the contained value usingOptional.ofNullable(Object)
.private <U> Try<U>
uncheckedCast()
-
-
-
Method Detail
-
andThenTry
public <U> Try<U> andThenTry(Try.Transformer<V,U> transformer)
Description copied from class:Try
If thisTry
is a success, apply the supplied transformer to its value and return a new successful or failedTry
depending on the transformer's outcome; if thisTry
is a failure, do nothing.- Specified by:
andThenTry
in classTry<V>
- Parameters:
transformer
- the transformer to try; must not benull
- Returns:
- a succeeded or failed
Try
; nevernull
-
andThen
public <U> Try<U> andThen(java.util.function.Function<V,Try<U>> function)
Description copied from class:Try
If thisTry
is a success, apply the supplied function to its value and return the resultingTry
; if thisTry
is a failure, do nothing.
-
uncheckedCast
private <U> Try<U> uncheckedCast()
-
orElseTry
public Try<V> orElseTry(java.util.concurrent.Callable<V> action)
Description copied from class:Try
If thisTry
is a failure, call the supplied action and return a new successful or failedTry
depending on the action's outcome; if thisTry
is a success, do nothing.
-
orElse
public Try<V> orElse(java.util.function.Supplier<Try<V>> supplier)
Description copied from class:Try
If thisTry
is a failure, call the supplied supplier and return the resultingTry
; if thisTry
is a success, do nothing.
-
get
public V get() throws java.lang.Exception
Description copied from class:Try
If thisTry
is a success, get the contained value; if thisTry
is a failure, throw the contained exception.
-
getOrThrow
public <E extends java.lang.Exception> V getOrThrow(java.util.function.Function<? super java.lang.Exception,E> exceptionTransformer) throws E extends java.lang.Exception
Description copied from class:Try
If thisTry
is a success, get the contained value; if thisTry
is a failure, call the suppliedFunction
with the contained exception and throw the resultingException
.- Specified by:
getOrThrow
in classTry<V>
- Parameters:
exceptionTransformer
- the transformer to be called with the contained exception, if available; must not benull
- Returns:
- the contained value, if available
- Throws:
E
- if thisTry
is a failureE extends java.lang.Exception
-
ifSuccess
public Try<V> ifSuccess(java.util.function.Consumer<V> valueConsumer)
Description copied from class:Try
If thisTry
is a success, call the suppliedConsumer
with the contained value; otherwise, do nothing.
-
ifFailure
public Try<V> ifFailure(java.util.function.Consumer<java.lang.Exception> causeConsumer)
Description copied from class:Try
If thisTry
is a failure, call the suppliedConsumer
with the contained exception; otherwise, do nothing.
-
toOptional
public java.util.Optional<V> toOptional()
Description copied from class:Try
If thisTry
is a failure, return an emptyOptional
; if thisTry
is a success, wrap the contained value usingOptional.ofNullable(Object)
.- Specified by:
toOptional
in classTry<V>
- Returns:
- an
Optional
; nevernull
but potentially empty
-
equals
public boolean equals(java.lang.Object that)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-