public abstract class TryX<T> extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
TryX() |
| Modifier and Type | Method and Description |
|---|---|
static <U> TryX<U> |
failure(RuntimeException e)
Factory method for failure.
|
abstract <U> TryX<U> |
flatMap(com.google.common.base.Function<? super T,TryX<U>> f)
Transform success or pass on failure, taking a Try as the result.
|
abstract T |
get()
Gets the value on Success or throws the cause of the failure.
|
abstract boolean |
isSuccess() |
abstract <U> TryX<U> |
map(com.google.common.base.Function<? super T,? extends U> f)
Transform success or pass on failure.
|
static <U> TryX<U> |
ofFailable(com.google.common.base.Supplier<U> f) |
abstract <F> TryX<T> |
onFailure(com.google.common.base.Function<RuntimeException,F> f) |
abstract T |
orElse(T value)
Return a value in the case of a failure.
|
abstract TryX<T> |
orElseTry(com.google.common.base.Supplier<T> f)
Return another try in the case of failure.
|
abstract T |
recover(com.google.common.base.Function<? super RuntimeException,T> f)
Specifies a result to use in case of failure.
|
abstract TryX<T> |
recoverWith(com.google.common.base.Function<? super RuntimeException,TryX<T>> f)
Try applying f(t) on the case of failure.
|
static <U> TryX<U> |
successful(U x)
Factory method for success.
|
public static <U> TryX<U> ofFailable(com.google.common.base.Supplier<U> f)
public abstract <U> TryX<U> map(com.google.common.base.Function<? super T,? extends U> f)
Try.ofFailable(() -> "1").
U - new type (optional)f - function to apply to successful value.public abstract <U> TryX<U> flatMap(com.google.common.base.Function<? super T,TryX<U>> f)
Try.ofFailable(() -> "1").
U - new type (optional)f - function to apply to successful value.public abstract T recover(com.google.common.base.Function<? super RuntimeException,T> f)
Try.ofFailable(() -> "not a number")
.
f - public abstract TryX<T> recoverWith(com.google.common.base.Function<? super RuntimeException,TryX<T>> f)
f - public abstract T orElse(T value)
value - public abstract TryX<T> orElseTry(com.google.common.base.Supplier<T> f)
f - public abstract T get()
public abstract boolean isSuccess()
public abstract <F> TryX<T> onFailure(com.google.common.base.Function<RuntimeException,F> f)
public static <U> TryX<U> failure(RuntimeException e)
U - e - public static <U> TryX<U> successful(U x)
U - x - Copyright © 2016. All rights reserved.