Class AbstractDeferred

    • Constructor Detail

      • AbstractDeferred

        public AbstractDeferred()
    • Method Detail

      • resolve

        protected boolean resolve​(Object... values)
        Resolves the promise. NOTE: The thread resolving the promise will be used to execute waiting listeners.
        Parameters:
        values - the result which resolves the Deferred.
        Returns:
        true if the promise is resolved; false in case the promise is already settled.
      • reject

        protected boolean reject​(JoynrException error)
        Rejects the promise. NOTE: The thread rejecting the promise will be used to execute waiting listeners.
        Parameters:
        error - the reason that caused the rejection.
        Returns:
        true if the promise is rejected; false in case the promise is already settled.
      • reject

        public boolean reject​(ProviderRuntimeException error)
        Rejects the promise. NOTE: The thread rejecting the promise will be used to execute waiting listeners.
        Parameters:
        error - the reason that caused the rejection.
        Returns:
        true if the promise is rejected; false in case the promise is already settled.
      • getError

        public Optional<JoynrException> getError()
        Returns:
        the error that caused the rejection of the deferred; null if the deferred is not in rejected state.
      • getValues

        public Optional<Object[]> getValues()
        Returns:
        the values that caused the fulfillment of the deferred; null if the deferred is not in fulfilled state.
      • addListener

        public void addListener​(DeferredListener listener)
        Adds a listener that is called once the deferred is settled. NOTE: If the deferred is already settled when adding the listener, the thread adding the listener will be used to execute the listener.
        Parameters:
        listener - the listener to add.
      • isFulfilled

        public boolean isFulfilled()
      • isRejected

        public boolean isRejected()
      • isSettled

        public boolean isSettled()
        Returns:
        true if the promise is fulfilled or rejected; false if the promise is pending.