- java.lang.Object
-
- org.junit.platform.commons.function.Try<V>
-
- org.junit.platform.commons.function.Try.Success<V>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.junit.platform.commons.function.Try
Try.Transformer<S,T>
-
-
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)
.
-
-
-
Field Detail
-
value
private final V value
-
-
Constructor Detail
-
Success
Success(V value)
-
-
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.
-
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()
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)
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
-
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
-
-