Class Promise<T>

  • Direct Known Subclasses:
    ApolloWSConnectionInitEvent, BaseBridgeEvent, ConnectionInitEvent

    public class Promise<T>
    extends Object
    Represents the writable side of an action that may, or may not, have occurred yet.

    The future() method returns the Future associated with a promise, the future can be used for getting notified of the promise completion and retrieve its value.

    A promise extends Handler> so it can be used as a callback.

    NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.

    • Constructor Detail

      • Promise

        public Promise​(Promise delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getDelegate

        public Promise getDelegate()
      • promise

        public static <T> Promise<T> promise()
        Create a promise that hasn't completed yet
        Returns:
        the promise
      • complete

        public void complete​(T result)
        Set the result. Any handler will be called, if there is one, and the promise will be marked as completed.

        Any handler set on the associated promise will be called.

        Parameters:
        result - the result
      • complete

        public void complete()
        Calls complete(null)
      • fail

        public void fail​(Throwable cause)
        Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.
        Parameters:
        cause - the failure cause
      • tryComplete

        public boolean tryComplete​(T result)
        Like complete(T) but returns false when the promise is already completed instead of throwing an IllegalStateException, it returns true otherwise.
        Parameters:
        result - the result
        Returns:
        false when the future is already completed
      • tryComplete

        public boolean tryComplete()
        Calls tryComplete(null).
        Returns:
        false when the future is already completed
      • tryFail

        public boolean tryFail​(Throwable cause)
        Like fail(java.lang.Throwable) but returns false when the promise is already completed instead of throwing an IllegalStateException, it returns true otherwise.
        Parameters:
        cause - the failure cause
        Returns:
        false when the future is already completed
      • tryFail

        public boolean tryFail​(String message)
        Calls fail(java.lang.Throwable) with the message.
        Parameters:
        message - the failure message
        Returns:
        false when the future is already completed
      • future

        public Future<T> future()
        Returns:
        the Future associated with this promise, it can be used to be aware of the promise completion
      • newInstance

        public static <T> Promise<T> newInstance​(Promise arg)