Class Try.Success<V>
- 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 thisTryis a success, apply the supplied function to its value and return the resultingTry; if thisTryis a failure, do nothing.<U> Try<U>andThenTry(Try.Transformer<V,U> transformer)If thisTryis a success, apply the supplied transformer to its value and return a new successful or failedTrydepending on the transformer's outcome; if thisTryis a failure, do nothing.booleanequals(java.lang.Object that)Vget()If thisTryis a success, get the contained value; if thisTryis a failure, throw the contained exception.<E extends java.lang.Exception>
VgetOrThrow(java.util.function.Function<? super java.lang.Exception,E> exceptionTransformer)If thisTryis a success, get the contained value; if thisTryis a failure, call the suppliedFunctionwith the contained exception and throw the resultingException.inthashCode()Try<V>ifFailure(java.util.function.Consumer<java.lang.Exception> causeConsumer)If thisTryis a failure, call the suppliedConsumerwith the contained exception; otherwise, do nothing.Try<V>ifSuccess(java.util.function.Consumer<V> valueConsumer)If thisTryis a success, call the suppliedConsumerwith the contained value; otherwise, do nothing.Try<V>orElse(java.util.function.Supplier<Try<V>> supplier)If thisTryis a failure, call the supplied supplier and return the resultingTry; if thisTryis a success, do nothing.Try<V>orElseTry(java.util.concurrent.Callable<V> action)If thisTryis a failure, call the supplied action and return a new successful or failedTrydepending on the action's outcome; if thisTryis a success, do nothing.java.util.Optional<V>toOptional()If thisTryis a failure, return an emptyOptional; if thisTryis 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:TryIf thisTryis a success, apply the supplied transformer to its value and return a new successful or failedTrydepending on the transformer's outcome; if thisTryis a failure, do nothing.- Specified by:
andThenTryin 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:TryIf thisTryis a success, apply the supplied function to its value and return the resultingTry; if thisTryis a failure, do nothing.
-
orElseTry
public Try<V> orElseTry(java.util.concurrent.Callable<V> action)
Description copied from class:TryIf thisTryis a failure, call the supplied action and return a new successful or failedTrydepending on the action's outcome; if thisTryis a success, do nothing.
-
orElse
public Try<V> orElse(java.util.function.Supplier<Try<V>> supplier)
Description copied from class:TryIf thisTryis a failure, call the supplied supplier and return the resultingTry; if thisTryis a success, do nothing.
-
get
public V get()
Description copied from class:TryIf thisTryis a success, get the contained value; if thisTryis 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:TryIf thisTryis a success, get the contained value; if thisTryis a failure, call the suppliedFunctionwith the contained exception and throw the resultingException.- Specified by:
getOrThrowin 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:TryIf thisTryis a success, call the suppliedConsumerwith the contained value; otherwise, do nothing.
-
ifFailure
public Try<V> ifFailure(java.util.function.Consumer<java.lang.Exception> causeConsumer)
Description copied from class:TryIf thisTryis a failure, call the suppliedConsumerwith the contained exception; otherwise, do nothing.
-
toOptional
public java.util.Optional<V> toOptional()
Description copied from class:TryIf thisTryis a failure, return an emptyOptional; if thisTryis a success, wrap the contained value usingOptional.ofNullable(Object).- Specified by:
toOptionalin classTry<V>- Returns:
- an
Optional; nevernullbut potentially empty
-
equals
public boolean equals(java.lang.Object that)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-