org.springframework.data.redis.support.collections
Class DefaultRedisZSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by org.springframework.data.redis.support.collections.AbstractRedisCollection<E>
          extended by org.springframework.data.redis.support.collections.DefaultRedisZSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, BoundKeyOperations<String>, RedisCollection<E>, RedisStore, RedisZSet<E>

public class DefaultRedisZSet<E>
extends AbstractRedisCollection<E>
implements RedisZSet<E>

Default implementation for RedisZSet.


Field Summary
 
Fields inherited from class org.springframework.data.redis.support.collections.AbstractRedisCollection
ENCODING
 
Constructor Summary
DefaultRedisZSet(BoundZSetOperations<String,E> boundOps)
          Constructs a new DefaultRedisZSet instance with a default score of '1'.
DefaultRedisZSet(BoundZSetOperations<String,E> boundOps, double defaultScore)
          Constructs a new DefaultRedisZSet instance.
DefaultRedisZSet(String key, RedisOperations<String,E> operations)
          Constructs a new DefaultRedisZSet instance with a default score of '1'.
DefaultRedisZSet(String key, RedisOperations<String,E> operations, double defaultScore)
          Constructs a new DefaultRedisSortedSet instance.
 
Method Summary
 boolean add(E e)
          Adds an element to the set with a default score.
 boolean add(E e, double score)
          Adds an element to the set with the given score, or updates the score if the element exists.
 void clear()
           
 boolean contains(Object o)
           
 E first()
          Returns the first (lowest) element currently in this sorted set.
 Double getDefaultScore()
          Returns the default score used by this set.
 DataType getType()
          Returns the associated Redis type.
 RedisZSet<E> intersectAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
           
 RedisZSet<E> intersectAndStore(RedisZSet<?> set, String destKey)
           
 Iterator<E> iterator()
           
 E last()
          Returns the last (highest) element currently in this sorted set.
 Set<E> range(long start, long end)
           
 Set<E> rangeByScore(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> rangeByScoreWithScores(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> rangeWithScores(long start, long end)
           
 Long rank(Object o)
          Returns the rank (position) of the given element in the set, in ascending order.
 RedisZSet<E> remove(long start, long end)
           
 boolean remove(Object o)
           
 RedisZSet<E> removeByScore(double min, double max)
           
 Set<E> reverseRange(long start, long end)
           
 Set<E> reverseRangeByScore(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> reverseRangeByScoreWithScores(double min, double max)
           
 Set<ZSetOperations.TypedTuple<E>> reverseRangeWithScores(long start, long end)
           
 Long reverseRank(Object o)
          Returns the rank (position) of the given element in the set, in descending order.
 Double score(Object o)
          Returns the score of the given element.
 int size()
           
 RedisZSet<E> unionAndStore(Collection<? extends RedisZSet<?>> sets, String destKey)
           
 RedisZSet<E> unionAndStore(RedisZSet<?> set, String destKey)
           
 
Methods inherited from class org.springframework.data.redis.support.collections.AbstractRedisCollection
addAll, containsAll, equals, expire, expireAt, getExpire, getKey, getOperations, hashCode, persist, removeAll, rename, retainAll, toString
 
Methods inherited from class java.util.AbstractCollection
isEmpty, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.data.redis.support.collections.RedisStore
getOperations
 
Methods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expire, expireAt, getExpire, getKey, persist, rename
 
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

DefaultRedisZSet

public DefaultRedisZSet(String key,
                        RedisOperations<String,E> operations)
Constructs a new DefaultRedisZSet instance with a default score of '1'.

Parameters:
key -
operations -

DefaultRedisZSet

public DefaultRedisZSet(String key,
                        RedisOperations<String,E> operations,
                        double defaultScore)
Constructs a new DefaultRedisSortedSet instance.

Parameters:
key -
operations -
defaultScore -

DefaultRedisZSet

public DefaultRedisZSet(BoundZSetOperations<String,E> boundOps)
Constructs a new DefaultRedisZSet instance with a default score of '1'.

Parameters:
boundOps -

DefaultRedisZSet

public DefaultRedisZSet(BoundZSetOperations<String,E> boundOps,
                        double defaultScore)
Constructs a new DefaultRedisZSet instance.

Parameters:
boundOps -
defaultScore -
Method Detail

intersectAndStore

public RedisZSet<E> intersectAndStore(RedisZSet<?> set,
                                      String destKey)
Specified by:
intersectAndStore in interface RedisZSet<E>

intersectAndStore

public RedisZSet<E> intersectAndStore(Collection<? extends RedisZSet<?>> sets,
                                      String destKey)
Specified by:
intersectAndStore in interface RedisZSet<E>

range

public Set<E> range(long start,
                    long end)
Specified by:
range in interface RedisZSet<E>

reverseRange

public Set<E> reverseRange(long start,
                           long end)
Specified by:
reverseRange in interface RedisZSet<E>

rangeByScore

public Set<E> rangeByScore(double min,
                           double max)
Specified by:
rangeByScore in interface RedisZSet<E>

reverseRangeByScore

public Set<E> reverseRangeByScore(double min,
                                  double max)
Specified by:
reverseRangeByScore in interface RedisZSet<E>

rangeByScoreWithScores

public Set<ZSetOperations.TypedTuple<E>> rangeByScoreWithScores(double min,
                                                                double max)
Specified by:
rangeByScoreWithScores in interface RedisZSet<E>

rangeWithScores

public Set<ZSetOperations.TypedTuple<E>> rangeWithScores(long start,
                                                         long end)
Specified by:
rangeWithScores in interface RedisZSet<E>

reverseRangeByScoreWithScores

public Set<ZSetOperations.TypedTuple<E>> reverseRangeByScoreWithScores(double min,
                                                                       double max)
Specified by:
reverseRangeByScoreWithScores in interface RedisZSet<E>

reverseRangeWithScores

public Set<ZSetOperations.TypedTuple<E>> reverseRangeWithScores(long start,
                                                                long end)
Specified by:
reverseRangeWithScores in interface RedisZSet<E>

remove

public RedisZSet<E> remove(long start,
                           long end)
Specified by:
remove in interface RedisZSet<E>

removeByScore

public RedisZSet<E> removeByScore(double min,
                                  double max)
Specified by:
removeByScore in interface RedisZSet<E>

unionAndStore

public RedisZSet<E> unionAndStore(RedisZSet<?> set,
                                  String destKey)
Specified by:
unionAndStore in interface RedisZSet<E>

unionAndStore

public RedisZSet<E> unionAndStore(Collection<? extends RedisZSet<?>> sets,
                                  String destKey)
Specified by:
unionAndStore in interface RedisZSet<E>

add

public boolean add(E e)
Description copied from interface: RedisZSet
Adds an element to the set with a default score. Equivalent to add(e, getDefaultScore()). The score value is implementation specific.

Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Specified by:
add in interface RedisZSet<E>
Specified by:
add in class AbstractRedisCollection<E>

add

public boolean add(E e,
                   double score)
Description copied from interface: RedisZSet
Adds an element to the set with the given score, or updates the score if the element exists.

Specified by:
add in interface RedisZSet<E>
Parameters:
e - element to add
score - element score
Returns:
true if a new element was added, false otherwise (only the score has been updated)

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Specified by:
clear in class AbstractRedisCollection<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>
Overrides:
contains in class AbstractCollection<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Specified by:
iterator in class AbstractCollection<E>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Specified by:
remove in class AbstractRedisCollection<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Specified by:
size in class AbstractCollection<E>

getDefaultScore

public Double getDefaultScore()
Description copied from interface: RedisZSet
Returns the default score used by this set.

Specified by:
getDefaultScore in interface RedisZSet<E>
Returns:
the default score used by the implementation.

first

public E first()
Description copied from interface: RedisZSet
Returns the first (lowest) element currently in this sorted set.

Specified by:
first in interface RedisZSet<E>
Returns:
the first (lowest) element currently in this sorted set.

last

public E last()
Description copied from interface: RedisZSet
Returns the last (highest) element currently in this sorted set.

Specified by:
last in interface RedisZSet<E>
Returns:
the last (highest) element currently in this sorted set.

rank

public Long rank(Object o)
Description copied from interface: RedisZSet
Returns the rank (position) of the given element in the set, in ascending order. Returns null if the element is not contained by the set.

Specified by:
rank in interface RedisZSet<E>
Parameters:
o - object
Returns:
rank of the given object

reverseRank

public Long reverseRank(Object o)
Description copied from interface: RedisZSet
Returns the rank (position) of the given element in the set, in descending order. Returns null if the element is not contained by the set.

Specified by:
reverseRank in interface RedisZSet<E>
Parameters:
o - object
Returns:
reverse rank of the given object

score

public Double score(Object o)
Description copied from interface: RedisZSet
Returns the score of the given element. Returns null if the element is not contained by the set.

Specified by:
score in interface RedisZSet<E>
Parameters:
o - object
Returns:
the score associated with the given object

getType

public DataType getType()
Description copied from interface: BoundKeyOperations
Returns the associated Redis type.

Specified by:
getType in interface BoundKeyOperations<String>
Returns:
key type