T
- The type of the value represented by this instancepublic final class Success<T> extends Object implements Try<T>, Serializable
Try
. Try
.Constructor and Description |
---|
Success(T value)
Creates a 'successful' instance with the provided value.
|
Modifier and Type | Method and Description |
---|---|
Try<Throwable> |
failed()
Returns a
Failure with an UnsupportedOperationException . |
<R> Try<R> |
flatMap(java.util.function.Function<T,Try<R>> function)
Applies the value to the function and returns the
Try generated by the function.. |
T |
get()
Returns the value provided in the constructor.
|
T |
getOrElse(java.util.function.Supplier<T> supplier)
Returns the value provided in the constructor.
|
boolean |
isSuccess()
Always returns
true . |
<R> Try<R> |
map(java.util.function.Function<T,R> function)
Applies the value to the function and returns the
Try representing the mapped value. |
Try<T> |
orElse(java.util.function.Supplier<Try<T>> supplier)
Always returns this.
|
String |
toString()
Returns a String representation of the instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
apply, apply, asOption, isFailure, iterator, orNull, stream
forEach, spliterator
public Success(T value)
value
- The value represented by this instancepublic boolean isSuccess()
true
.public T getOrElse(java.util.function.Supplier<T> supplier)
public Try<T> orElse(java.util.function.Supplier<Try<T>> supplier)
public T get()
public Try<Throwable> failed()
Failure
with an UnsupportedOperationException
. public <R> Try<R> map(java.util.function.Function<T,R> function)
Try
representing the mapped value.public <R> Try<R> flatMap(java.util.function.Function<T,Try<R>> function)
Try
generated by the function..Copyright © 2015, Peter Nerg Apache License v2.0