T
- The type of the value represented by this instancepublic final class Success<T> extends Object implements Try<T>, Serializable
Try
.Constructor and Description |
---|
Success(T value)
Creates a 'successful' instance with the provided value.
Null values are allowed. |
Modifier and Type | Method and Description |
---|---|
Try<Throwable> |
failed()
Always returns a
Failure with an UnsupportedOperationException . |
<R> Try<R> |
flatMap(java.util.function.Function<T,Try<R>> function)
|
T |
get()
Always returns the value provided in the constructor.
|
T |
getOrElse(java.util.function.Supplier<T> s)
Always 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>> s)
Always returns this.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
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> s)
public Try<T> orElse(java.util.function.Supplier<Try<T>> s)
public T get()
public Try<Throwable> failed()
Failure
with an UnsupportedOperationException
.public <R> Try<R> map(java.util.function.Function<T,R> function)
public <R> Try<R> flatMap(java.util.function.Function<T,Try<R>> function)
Try
Copyright © 2015. All rights reserved.