Module lettuce.core

Class CommandWrapper<K,​V,​T>

java.lang.Object
io.lettuce.core.protocol.CommandWrapper<K,​V,​T>
All Implemented Interfaces:
CompleteableCommand<T>, DecoratedCommand<K,​V,​T>, RedisCommand<K,​V,​T>
Direct Known Subclasses:
TracedCommand

public class CommandWrapper<K,​V,​T>
extends Object
implements RedisCommand<K,​V,​T>, CompleteableCommand<T>, DecoratedCommand<K,​V,​T>
Wrapper for a command.
Author:
Mark Paluch
  • Field Details

  • Constructor Details

    • CommandWrapper

      public CommandWrapper​(RedisCommand<K,​V,​T> command)
  • Method Details

    • getOutput

      public CommandOutput<K,​V,​T> getOutput()
      Description copied from interface: RedisCommand
      The command output. Can be null.
      Specified by:
      getOutput in interface RedisCommand<K,​V,​T>
      Returns:
      the command output.
    • complete

      public void complete()
      Description copied from interface: RedisCommand
      Complete a command.
      Specified by:
      complete in interface RedisCommand<K,​V,​T>
    • doOnComplete

      protected void doOnComplete()
      Callback method called after successful completion and before notifying downstream consumers.
      Since:
      6.0.2
    • cancel

      public void cancel()
      Description copied from interface: RedisCommand
      Attempts to cancel execution of this command. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason.
      Specified by:
      cancel in interface RedisCommand<K,​V,​T>
    • completeExceptionally

      public boolean completeExceptionally​(Throwable throwable)
      Description copied from interface: RedisCommand
      Complete this command by attaching the given exception.
      Specified by:
      completeExceptionally in interface RedisCommand<K,​V,​T>
      Parameters:
      throwable - the exception
      Returns:
      true if this invocation caused this CompletableFuture to transition to a completed state, else false
    • doOnError

      protected void doOnError​(Throwable throwable)
      Callback method called after error completion and before notifying downstream consumers.
      Parameters:
      throwable -
      Since:
      6.0.2
    • getArgs

      public CommandArgs<K,​V> getArgs()
      Specified by:
      getArgs in interface RedisCommand<K,​V,​T>
      Returns:
      the current command args.
    • getType

      public ProtocolKeyword getType()
      Specified by:
      getType in interface RedisCommand<K,​V,​T>
      Returns:
      the Redis command type like SADD, HMSET, QUIT.
    • encode

      public void encode​(ByteBuf buf)
      Description copied from interface: RedisCommand
      Encode the command.
      Specified by:
      encode in interface RedisCommand<K,​V,​T>
      Parameters:
      buf - byte buffer to operate on.
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: RedisCommand
      Returns true if this task was cancelled before it completed normally.
      Specified by:
      isCancelled in interface RedisCommand<K,​V,​T>
      Returns:
      true if the command was cancelled before it completed normally.
    • setOutput

      public void setOutput​(CommandOutput<K,​V,​T> output)
      Description copied from interface: RedisCommand
      Set a new output. Only possible as long as the command is not completed/cancelled.
      Specified by:
      setOutput in interface RedisCommand<K,​V,​T>
      Parameters:
      output - the new command output
    • onComplete

      public void onComplete​(Consumer<? super T> action)
      Description copied from interface: CompleteableCommand
      Register a command callback for successive command completion that notifies the callback with the command result.
      Specified by:
      onComplete in interface CompleteableCommand<K>
      Parameters:
      action - must not be null.
    • onComplete

      public void onComplete​(BiConsumer<? super T,​Throwable> action)
      Description copied from interface: CompleteableCommand
      Register a command callback for command completion that notifies the callback with the command result or the failure resulting from command completion.
      Specified by:
      onComplete in interface CompleteableCommand<K>
      Parameters:
      action - must not be null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isDone

      public boolean isDone()
      Description copied from interface: RedisCommand
      Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation. In all of these cases, this method will return true.
      Specified by:
      isDone in interface RedisCommand<K,​V,​T>
      Returns:
      true if this task completed.
    • getDelegate

      public RedisCommand<K,​V,​T> getDelegate()
      Description copied from interface: DecoratedCommand
      The underlying command.
      Specified by:
      getDelegate in interface DecoratedCommand<K,​V,​T>
      Returns:
      never null.
    • unwrap

      public static <K,​ V,​ T> RedisCommand<K,​V,​T> unwrap​(RedisCommand<K,​V,​T> wrapped)
      Unwrap a wrapped command.
      Parameters:
      wrapped -
      Returns:
    • unwrap

      public static <R,​ K,​ V,​ T> R unwrap​(RedisCommand<K,​V,​T> wrapped, Class<R> iface)
      Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an null is returned.
      Parameters:
      wrapped -
      iface - A Class defining an interface that the result must implement.
      Returns:
      the unwrapped instance or null.
      Since:
      5.1
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object