Class ConvertingCursor<S,T>

java.lang.Object
org.springframework.data.redis.core.ConvertingCursor<S,T>
Type Parameters:
S -
T -
All Implemented Interfaces:
Closeable, AutoCloseable, Iterator<T>, Cursor<T>, CloseableIterator<T>

public class ConvertingCursor<S,T> extends Object implements Cursor<T>
ConvertingCursor wraps a given cursor and applies given Converter to items prior to returning them. This allows to easily perform required conversion whereas the underlying implementation may still work with its native types.
Since:
1.4
Author:
Christoph Strobl
  • Constructor Details

    • ConvertingCursor

      public ConvertingCursor(Cursor<S> cursor, Converter<S,T> converter)
      Parameters:
      cursor - Cursor must not be null.
      converter - Converter must not be null.
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<S>
    • next

      @Nullable public T next()
      Specified by:
      next in interface Iterator<S>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<S>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface CloseableIterator<S>
    • getCursorId

      public long getCursorId()
      Description copied from interface: Cursor
      Get the reference cursor.
      NOTE: the id might change while iterating items.
      Specified by:
      getCursorId in interface Cursor<S>
      Returns:
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface Cursor<S>
      Returns:
      true if cursor closed.
    • getPosition

      public long getPosition()
      Specified by:
      getPosition in interface Cursor<S>
      Returns:
      the current position of the cursor.