Package | Description |
---|---|
javascalautils |
Contains various utility classes translated from the Scala language.
|
javascalautils.concurrent |
Contains utilities for concurrent/asynchronous programming.
|
Modifier and Type | Class and Description |
---|---|
class |
Failure<T>
Represents the failure implementation of
Try . |
class |
Success<T>
Represents the successful implementation of
Try . |
Modifier and Type | Method and Description |
---|---|
static <T> Try<T> |
Try.apply(T value)
Creates an instance of Try.
|
static <T> Try<T> |
Try.apply(ThrowableFunction0<T> function)
Creates an instance of Try wrapping the result of the provided function.
|
Try<Throwable> |
Success.failed()
Returns a
Failure with an UnsupportedOperationException . |
Try<Throwable> |
Try.failed()
Completes this Try with an exception wrapped in a
Success . |
Try<Throwable> |
Failure.failed()
|
Try<T> |
Success.filter(java.util.function.Predicate<T> predicate)
Applies the predicate to the value of this instance, if it matches this is returned else a
Failure . |
Try<T> |
Try.filter(java.util.function.Predicate<T> filter)
|
Try<T> |
Failure.filter(java.util.function.Predicate<T> predicate)
Always returns this.
|
<R> Try<R> |
Success.flatMap(java.util.function.Function<T,Try<R>> function)
Applies the value to the function and returns the
Try generated by the function. |
<R> Try<R> |
Try.flatMap(java.util.function.Function<T,Try<R>> function)
|
<R> Try<R> |
Failure.flatMap(java.util.function.Function<T,Try<R>> function)
Always returns this.
|
<R> Try<R> |
Success.map(java.util.function.Function<T,R> function)
Applies the value to the function and returns the
Try representing the mapped value. |
<R> Try<R> |
Try.map(java.util.function.Function<T,R> function)
|
<R> Try<R> |
Failure.map(java.util.function.Function<T,R> function)
Always returns this.
|
Try<T> |
Success.orElse(java.util.function.Supplier<Try<T>> supplier)
Always returns this.
|
Try<T> |
Try.orElse(java.util.function.Supplier<Try<T>> supplier)
|
Try<T> |
Failure.orElse(java.util.function.Supplier<Try<T>> supplier)
Always returns the value provided by the supplier.
|
Try<T> |
Success.recover(java.util.function.Function<Throwable,T> function)
Always returns this .
|
Try<T> |
Try.recover(java.util.function.Function<Throwable,T> function)
|
Try<T> |
Failure.recover(java.util.function.Function<Throwable,T> function)
|
Try<T> |
Success.recoverWith(java.util.function.Function<Throwable,Try<T>> function)
Always returns this .
|
Try<T> |
Try.recoverWith(java.util.function.Function<Throwable,Try<T>> function)
|
Try<T> |
Failure.recoverWith(java.util.function.Function<Throwable,Try<T>> function)
Applies the provided function to the Throwable of this
Failure and returns the result. |
static <T> Try<T> |
TryCompanion.Try(ThrowableFunction0<T> function)
Creates an instance of
Try wrapping the result of the provided function. |
Modifier and Type | Method and Description |
---|---|
<R> Try<R> |
Success.flatMap(java.util.function.Function<T,Try<R>> function)
Applies the value to the function and returns the
Try generated by the function. |
<R> Try<R> |
Try.flatMap(java.util.function.Function<T,Try<R>> function)
|
<R> Try<R> |
Failure.flatMap(java.util.function.Function<T,Try<R>> function)
Always returns this.
|
Try<T> |
Success.orElse(java.util.function.Supplier<Try<T>> supplier)
Always returns this.
|
Try<T> |
Try.orElse(java.util.function.Supplier<Try<T>> supplier)
|
Try<T> |
Failure.orElse(java.util.function.Supplier<Try<T>> supplier)
Always returns the value provided by the supplier.
|
Try<T> |
Success.recoverWith(java.util.function.Function<Throwable,Try<T>> function)
Always returns this .
|
Try<T> |
Try.recoverWith(java.util.function.Function<Throwable,Try<T>> function)
|
Try<T> |
Failure.recoverWith(java.util.function.Function<Throwable,Try<T>> function)
Applies the provided function to the Throwable of this
Failure and returns the result. |
Modifier and Type | Method and Description |
---|---|
Option<Try<T>> |
Future.value()
The current (completed or not) value of the future.
|
Modifier and Type | Method and Description |
---|---|
void |
Promise.complete(Try<T> result)
|
static <T> Future<T> |
Future.fromTry(Try<T> result)
Creates a completed Future with the provided Try.
|
boolean |
Promise.tryComplete(Try<T> result)
|
Modifier and Type | Method and Description |
---|---|
void |
Future.onComplete(java.util.function.Consumer<Try<T>> completeHandler)
Register a handler to be invoked if the Future gets completed with a value or a failure.
|
Copyright © 2015, Peter Nerg Apache License v2.0