Package io.vavr.control
Class Try.Success<T>
java.lang.Object
io.vavr.control.Try.Success<T>
- Type Parameters:
T- the type of the contained value
- All Implemented Interfaces:
Try<T>,Value<T>,Serializable,Iterable<T>
Represents a successful
Try containing a value.
Instances of this class indicate that the computation completed successfully
and hold the resulting value of type T.
Try<Integer> success = new Try.Success<>(42);
success.isSuccess(); // true
success.get(); // 42
- Author:
- Daniel Dietrich
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vavr.control.Try
Try.Failure<T>, Try.Success<T>, Try.WithResources1<T1 extends AutoCloseable>, Try.WithResources2<T1 extends AutoCloseable,T2 extends AutoCloseable>, Try.WithResources3<T1 extends AutoCloseable, T2 extends AutoCloseable, T3 extends AutoCloseable>, Try.WithResources4<T1 extends AutoCloseable, T2 extends AutoCloseable, T3 extends AutoCloseable, T4 extends AutoCloseable>, Try.WithResources5<T1 extends AutoCloseable, T2 extends AutoCloseable, T3 extends AutoCloseable, T4 extends AutoCloseable, T5 extends AutoCloseable>, Try.WithResources6<T1 extends AutoCloseable, T2 extends AutoCloseable, T3 extends AutoCloseable, T4 extends AutoCloseable, T5 extends AutoCloseable, T6 extends AutoCloseable>, Try.WithResources7<T1 extends AutoCloseable, T2 extends AutoCloseable, T3 extends AutoCloseable, T4 extends AutoCloseable, T5 extends AutoCloseable, T6 extends AutoCloseable, T7 extends AutoCloseable>, Try.WithResources8<T1 extends AutoCloseable, T2 extends AutoCloseable, T3 extends AutoCloseable, T4 extends AutoCloseable, T5 extends AutoCloseable, T6 extends AutoCloseable, T7 extends AutoCloseable, T8 extends AutoCloseable> -
Method Summary
Modifier and TypeMethodDescriptionbooleanClarifies that values have a proper equals() method implemented.get()Returns the value of thisTryif it is aTry.Success, or throws the underlying exception if it is aTry.Failure.getCause()Returns the cause of failure if thisTryis aTry.Failure.inthashCode()Clarifies that values have a proper hashCode() method implemented.booleanisEmpty()Checks whether thisTrycontains no value, i.e., it is aTry.Failure.booleanChecks whether thisTryis aTry.Failure.booleanChecks whether thisTryis aTry.Success.Returns the name of this Value type, which is used by toString().toString()Clarifies that values have a proper toString() method implemented.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.vavr.control.Try
andFinally, andFinallyTry, andThen, andThen, andThenTry, andThenTry, collect, failed, filter, filter, filter, filterTry, filterTry, filterTry, flatMap, flatMapTry, fold, getOrElseGet, getOrElseThrow, isAsync, isLazy, isSingleValued, iterator, map, mapFailure, mapTo, mapToVoid, mapTry, onFailure, onFailure, onSuccess, orElse, orElse, orElseRun, peek, recover, recover, recover, recoverAllAndTry, recoverAndTry, recoverWith, recoverWith, recoverWith, toEither, toEither, toValidation, toValidation, transformMethods inherited from interface io.vavr.Value
collect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, out, out, spliterator, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
-
Method Details
-
get
Description copied from interface:TryReturns the value of thisTryif it is aTry.Success, or throws the underlying exception if it is aTry.Failure.Important: If this
Tryis aTry.Failure, the exception thrown is exactly theTry.getCause()of thisFailure. The underlying cause is thrown sneakily (without being declared in the method signature). -
getCause
Description copied from interface:TryReturns the cause of failure if thisTryis aTry.Failure.- Specified by:
getCausein interfaceTry<T>- Returns:
- the throwable cause of this
Try.Failure
-
isEmpty
public boolean isEmpty()Description copied from interface:TryChecks whether thisTrycontains no value, i.e., it is aTry.Failure.- Specified by:
isEmptyin interfaceTry<T>- Specified by:
isEmptyin interfaceValue<T>- Returns:
trueif this is aTry.Failure,falseif this is aTry.Success
-
isFailure
public boolean isFailure()Description copied from interface:TryChecks whether thisTryis aTry.Failure.- Specified by:
isFailurein interfaceTry<T>- Returns:
trueif this is aTry.Failure,falseif this is aTry.Success
-
isSuccess
public boolean isSuccess()Description copied from interface:TryChecks whether thisTryis aTry.Success.- Specified by:
isSuccessin interfaceTry<T>- Returns:
trueif this is aTry.Success,falseif this is aTry.Failure
-
equals
Description copied from interface:ValueClarifies that values have a proper equals() method implemented. -
hashCode
public int hashCode()Description copied from interface:ValueClarifies that values have a proper hashCode() method implemented.See Object.hashCode().
-
stringPrefix
Description copied from interface:ValueReturns the name of this Value type, which is used by toString().- Specified by:
stringPrefixin interfaceValue<T>- Returns:
- This type name.
-
toString
Description copied from interface:ValueClarifies that values have a proper toString() method implemented.See Object.toString().
-