Class CompletePromise<T>

    • Constructor Detail

      • CompletePromise

        public CompletePromise()
    • Method Detail

      • isComplete

        public final boolean isComplete()
        Specified by:
        isComplete in interface Promise<T>
      • isResult

        public final boolean isResult()
        Specified by:
        isResult in interface Promise<T>
      • isException

        public final boolean isException()
        Specified by:
        isException in interface Promise<T>
      • getResult

        public abstract T getResult()
        Specified by:
        getResult in interface Promise<T>
      • getTry

        public io.activej.common.collection.Try<T> getTry()
        Specified by:
        getTry in interface Promise<T>
      • next

        @NotNull
        public final <U,​S extends Callback<? super T> & Promise<U>> @NotNull Promise<U> next​(@NotNull
                                                                                                   S promise)
        Description copied from interface: Promise
        Executes given promise after execution of this Promise completes.
        Specified by:
        next in interface Promise<T>
        Type Parameters:
        U - type of result
        Parameters:
        promise - given promise
        Returns:
        subscribed Promise
      • map

        @NotNull
        public final <U> @NotNull Promise<U> map​(@NotNull
                                                 @NotNull Function<? super T,​? extends U> fn)
        Description copied from interface: Promise
        Returns a new Promise which is executed with this Promise's result as the argument to the provided function when this Promise completes successfully.
        Specified by:
        map in interface Promise<T>
        Parameters:
        fn - function to be applied to this Promise when it completes successfully
        Returns:
        new Promise which is the result of function applied to the result of this Promise
        See Also:
        CompletionStage.thenApply(Function)
      • mapEx

        @NotNull
        public final <U> @NotNull Promise<U> mapEx​(@NotNull
                                                   @NotNull BiFunction<? super T,​Throwable,​? extends U> fn)
        Description copied from interface: Promise
        Returns a new Promise which is executed with this Promise's result as the argument to the provided function when this Promise completes either successfully (when exception is null) or with an exception.
        Specified by:
        mapEx in interface Promise<T>
        Parameters:
        fn - function to be applied to this Promise when it completes either successfully or with an exception
        Returns:
        new Promise which is the result of function applied to the result of this Promise
      • then

        @NotNull
        public final <U> @NotNull Promise<U> then​(@NotNull
                                                  @NotNull Function<? super T,​? extends Promise<? extends U>> fn)
        Description copied from interface: Promise
        Returns a new Promise which, when this Promise completes successfully, is executed with this Promise's result as the argument to the supplied function.
        Specified by:
        then in interface Promise<T>
        Parameters:
        fn - to be applied
      • thenEx

        @NotNull
        public final <U> @NotNull Promise<U> thenEx​(@NotNull
                                                    @NotNull BiFunction<? super T,​Throwable,​? extends Promise<? extends U>> fn)
        Description copied from interface: Promise
        Returns a new Promise which, when this Promise completes either successfully (if exception is null) or exceptionally (if exception is not null), is executed with this Promise's result as the argument to the supplied function.
        Specified by:
        thenEx in interface Promise<T>
        Parameters:
        fn - to be applied to the result of this Promise
        Returns:
        new Promise
      • whenComplete

        @NotNull
        public final @NotNull Promise<T> whenComplete​(@NotNull
                                                      @NotNull Callback<? super T> action)
        Description copied from interface: Promise
        Subscribes given action to be executed after this Promise completes and returns a new Promise.
        Specified by:
        whenComplete in interface Promise<T>
        Parameters:
        action - to be executed
      • whenComplete

        @NotNull
        public @NotNull Promise<T> whenComplete​(@NotNull
                                                @NotNull Runnable action)
        Description copied from interface: Promise
        Subscribes given action to be executed after this Promise completes and returns a new Promise.
        Specified by:
        whenComplete in interface Promise<T>
        Parameters:
        action - to be executed
      • whenResult

        @NotNull
        public final @NotNull Promise<T> whenResult​(@NotNull
                                                    @NotNull Consumer<? super T> action)
        Description copied from interface: Promise
        Subscribes given action to be executed after this Promise completes successfully and returns a new Promise.
        Specified by:
        whenResult in interface Promise<T>
        Parameters:
        action - to be executed
      • whenException

        public final Promise<T> whenException​(@NotNull
                                              @NotNull Consumer<Throwable> action)
        Description copied from interface: Promise
        Subscribes given action to be executed after this Promise completes exceptionally and returns a new Promise.
        Specified by:
        whenException in interface Promise<T>
        Parameters:
        action - to be executed
      • combine

        @NotNull
        public final <U,​V> @NotNull Promise<V> combine​(@NotNull
                                                             @NotNull Promise<? extends U> other,
                                                             @NotNull
                                                             @NotNull BiFunction<? super T,​? super U,​? extends V> fn)
        Description copied from interface: Promise
        Returns a new Promise that, when this and the other given Promise both complete, is executed with the two results as arguments to the supplied function.
        Specified by:
        combine in interface Promise<T>
        Parameters:
        other - the other Promise
        fn - the function to use to compute the value of the returned Promise
        Returns:
        new Promise
      • both

        @NotNull
        public final @NotNull Promise<Void> both​(@NotNull
                                                 @NotNull Promise<?> other)
        Description copied from interface: Promise
        Returns a new Promise when both this and provided other Promises complete.
        Specified by:
        both in interface Promise<T>
        Parameters:
        other - the other Promise
        Returns:
        Promise of null when both this and other Promise complete
      • either

        @NotNull
        public final @NotNull Promise<T> either​(@NotNull
                                                @NotNull Promise<? extends T> other)
        Description copied from interface: Promise
        Returns the Promise which was completed first.
        Specified by:
        either in interface Promise<T>
        Parameters:
        other - the other Promise
        Returns:
        the first completed Promise
      • async

        @NotNull
        public final @NotNull Promise<T> async()
        Description copied from interface: Promise
        Ensures that Promise completes asynchronously: if this Promise is already completed, its completion will be posted to next eventloop tick. Otherwise, does nothing.
        Specified by:
        async in interface Promise<T>
      • toTry

        @NotNull
        public final @NotNull Promise<io.activej.common.collection.Try<T>> toTry()
        Description copied from interface: Promise
        Returns Promise that always completes successfully with result or exception wrapped in Try.
        Specified by:
        toTry in interface Promise<T>
      • toVoid

        @NotNull
        public final @NotNull Promise<Void> toVoid()
        Description copied from interface: Promise
        Waits for result and discards it.
        Specified by:
        toVoid in interface Promise<T>