Represents the result of an action that may, or may not, have occurred yet.

  • Future
    • Basic
      • Identifiable
      • Object
        • Anything
Initializer
Future(Future<out Object> unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
causeshared default Throwable cause()

A Throwable describing failure. This will be null if the operation succeeded.

completeshared default void complete()

Set a null result. Any handler will be called, if there is one, and the future will be marked as completed.

completeshared default void complete(T? result)

Set the result. Any handler will be called, if there is one, and the future will be marked as completed.

Parameters:
  • result

    the result

completershared default Anything(Throwable|T?) completer()

@return an handler completing this future

composeshared default void compose<U>(Anything(T?) handler, Future<U> next)

Compose this future with another future.

When this future succeeds, the handler will be called with the value.

When this future fails, the failure will be propagated to the next future.

Parameters:
  • handler

    the handler

  • next

    the next future

failshared default void fail(String failureMessage)

Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

Parameters:
  • failureMessage

    the failure message

failshared default void fail(Throwable throwable)

Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

Parameters:
  • throwable

    the failure cause

failedshared default Boolean failed()

Did it fail?

isCompleteshared default Boolean isComplete()

Has the future completed?

It's completed if it's either succeeded or failed.

resultshared default T? result()

The result of the operation. This will be null if the operation failed.

setHandlershared default Future<T> setHandler(Anything(Throwable|T?) handler)

Set a handler for the result.

If the future has already been completed it will be called immediately. Otherwise it will be called when the future is completed.

Parameters:
  • handler

    the Handler that will be called with the result

succeededshared default Boolean succeeded()

Did it succeed?

Inherited Methods
Methods inherited from: Object
equals