Align newly added method names in RedisZSet to RedisSet.

And add some documentation to RedisSet along the way.

#Original Pull Request: #2097
This commit is contained in:
Christoph Strobl
2021-06-30 08:06:49 +02:00
parent d019ada080
commit 961ba9035d
4 changed files with 113 additions and 17 deletions

View File

@@ -110,7 +110,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
* @see org.springframework.data.redis.support.collections.RedisZSet#difference(org.springframework.data.redis.support.collections.RedisZSet)
*/
@Override
public Set<E> difference(RedisZSet<?> set) {
public Set<E> diff(RedisZSet<?> set) {
return boundZSetOps.difference(set.getKey());
}
@@ -119,7 +119,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
* @see org.springframework.data.redis.support.collections.RedisZSet#difference(java.util.Collection)
*/
@Override
public Set<E> difference(Collection<? extends RedisZSet<?>> sets) {
public Set<E> diff(Collection<? extends RedisZSet<?>> sets) {
return boundZSetOps.difference(CollectionUtils.extractKeys(sets));
}
@@ -128,7 +128,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
* @see org.springframework.data.redis.support.collections.RedisZSet#differenceWithScores(org.springframework.data.redis.support.collections.RedisZSet)
*/
@Override
public Set<TypedTuple<E>> differenceWithScores(RedisZSet<?> set) {
public Set<TypedTuple<E>> diffWithScores(RedisZSet<?> set) {
return boundZSetOps.differenceWithScores(set.getKey());
}
@@ -137,7 +137,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
* @see org.springframework.data.redis.support.collections.RedisZSet#differenceWithScores(java.util.Collection)
*/
@Override
public Set<TypedTuple<E>> differenceWithScores(Collection<? extends RedisZSet<?>> sets) {
public Set<TypedTuple<E>> diffWithScores(Collection<? extends RedisZSet<?>> sets) {
return boundZSetOps.differenceWithScores(CollectionUtils.extractKeys(sets));
}
@@ -146,7 +146,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
* @see org.springframework.data.redis.support.collections.RedisZSet#differenceAndStore(org.springframework.data.redis.support.collections.RedisZSet, java.lang.String)
*/
@Override
public RedisZSet<E> differenceAndStore(RedisZSet<?> set, String destKey) {
public RedisZSet<E> diffAndStore(RedisZSet<?> set, String destKey) {
boundZSetOps.differenceAndStore(set.getKey(), destKey);
return new DefaultRedisZSet<>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore());
@@ -157,7 +157,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
* @see org.springframework.data.redis.support.collections.RedisZSet#differenceAndStore(java.util.Collection, java.lang.String)
*/
@Override
public RedisZSet<E> differenceAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) {
public RedisZSet<E> diffAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) {
boundZSetOps.differenceAndStore(CollectionUtils.extractKeys(sets), destKey);
return new DefaultRedisZSet<>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore());

View File

@@ -27,28 +27,124 @@ import java.util.Set;
*/
public interface RedisSet<E> extends RedisCollection<E>, Set<E> {
/**
* Intersect this set and another {@link RedisSet}.
*
* @param set must not be {@literal null}.
* @return a {@link Set} containing the intersecting values.
* @since 1.0
*/
Set<E> intersect(RedisSet<?> set);
/**
* Intersect this set and other {@link RedisSet}s.
*
* @param sets must not be {@literal null}.
* @return a {@link Set} containing the intersecting values.
* @since 1.0
*/
Set<E> intersect(Collection<? extends RedisSet<?>> sets);
/**
* Union this set and another {@link RedisSet}.
*
* @param set must not be {@literal null}.
* @return a {@link Set} containing the combined values.
* @since 2.6
*/
Set<E> union(RedisSet<?> set);
/**
* Union this set and other {@link RedisSet}s.
*
* @param sets must not be {@literal null}.
* @return a {@link Set} containing the combined values.
* @since 1.0
*/
Set<E> union(Collection<? extends RedisSet<?>> sets);
/**
* Diff this set and another {@link RedisSet}.
*
* @param set must not be {@literal null}.
* @return a {@link Set} containing the values that differ.
* @since 1.0
*/
Set<E> diff(RedisSet<?> set);
/**
* Diff this set and other {@link RedisSet}s.
*
* @param sets must not be {@literal null}.
* @return a {@link Set} containing the values that differ.
* @since 1.0
*/
Set<E> diff(Collection<? extends RedisSet<?>> sets);
/**
* Create a new {@link RedisSet} by intersecting this sorted set and {@link RedisSet} and store result in
* destination {@code destKey}.
*
* @param set must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return a new {@link RedisSet} pointing at {@code destKey}
* @since 1.0
*/
RedisSet<E> intersectAndStore(RedisSet<?> set, String destKey);
/**
* Create a new {@link RedisSet} by intersecting this sorted set and the collection {@link RedisSet} and store
* result in destination {@code destKey}.
*
* @param sets must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return a new {@link RedisSet} pointing at {@code destKey}.
* @since 1.0
*/
RedisSet<E> intersectAndStore(Collection<? extends RedisSet<?>> sets, String destKey);
/**
* Create a new {@link RedisSet} by union this sorted set and {@link RedisSet} and store result in destination
* {@code destKey}.
*
* @param set must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return a new {@link RedisSet} pointing at {@code destKey}.
* @since 1.0
*/
RedisSet<E> unionAndStore(RedisSet<?> set, String destKey);
/**
* Create a new {@link RedisSet} by union this sorted set and the collection {@link RedisSet} and store result in
* destination {@code destKey}.
*
* @param sets must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return a new {@link RedisSet} pointing at {@code destKey}.
* @since 1.0
*/
RedisSet<E> unionAndStore(Collection<? extends RedisSet<?>> sets, String destKey);
/**
* Create a new {@link RedisSet} by diffing this sorted set and {@link RedisSet} and store result in destination
* {@code destKey}.
*
* @param set must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return a new {@link RedisSet} pointing at {@code destKey}.
* @since 1.0
*/
RedisSet<E> diffAndStore(RedisSet<?> set, String destKey);
/**
* Create a new {@link RedisSet} by diffing this sorted set and the collection {@link RedisSet} and store result in
* destination {@code destKey}.
*
* @param sets must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return a new {@link RedisSet} pointing at {@code destKey}.
* @since 1.0
*/
RedisSet<E> diffAndStore(Collection<? extends RedisSet<?>> sets, String destKey);
/**

View File

@@ -73,7 +73,7 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @return a {@link Set} containing the values that differ.
* @since 2.6
*/
Set<E> difference(RedisZSet<?> set);
Set<E> diff(RedisZSet<?> set);
/**
* Diff this set and other {@link RedisZSet}s.
@@ -82,7 +82,7 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @return a {@link Set} containing the values that differ.
* @since 2.6
*/
Set<E> difference(Collection<? extends RedisZSet<?>> sets);
Set<E> diff(Collection<? extends RedisZSet<?>> sets);
/**
* Diff this set and another {@link RedisZSet}.
@@ -91,16 +91,16 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @return a {@link Set} containing the values that differ with their scores.
* @since 2.6
*/
Set<TypedTuple<E>> differenceWithScores(RedisZSet<?> set);
Set<TypedTuple<E>> diffWithScores(RedisZSet<?> set);
/**
* Diff this set and other {@link RedisZSet}s.
*
* @param set must not be {@literal null}.
* @param sets must not be {@literal null}.
* @return a {@link Set} containing the values that differ with their scores.
* @since 2.6
*/
Set<TypedTuple<E>> differenceWithScores(Collection<? extends RedisZSet<?>> sets);
Set<TypedTuple<E>> diffWithScores(Collection<? extends RedisZSet<?>> sets);
/**
* Create a new {@link RedisZSet} by diffing this sorted set and {@link RedisZSet} and store result in destination
@@ -111,7 +111,7 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @return a new {@link RedisZSet} pointing at {@code destKey}.
* @since 2.6
*/
RedisZSet<E> differenceAndStore(RedisZSet<?> set, String destKey);
RedisZSet<E> diffAndStore(RedisZSet<?> set, String destKey);
/**
* Create a new {@link RedisZSet} by diffing this sorted set and the collection {@link RedisZSet} and store result in
@@ -122,7 +122,7 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
* @return a new {@link RedisZSet} pointing at {@code destKey}.
* @since 2.6
*/
RedisZSet<E> differenceAndStore(Collection<? extends RedisZSet<?>> sets, String destKey);
RedisZSet<E> diffAndStore(Collection<? extends RedisZSet<?>> sets, String destKey);
/**
* Intersect this set and another {@link RedisZSet}.
@@ -154,7 +154,7 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
/**
* Intersect this set and other {@link RedisZSet}s.
*
* @param set must not be {@literal null}.
* @param sets must not be {@literal null}.
* @return a {@link Set} containing the intersecting values with their scores.
* @since 2.6
*/