diff --git a/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java b/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java index d84a3fe48..d4687f855 100644 --- a/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java +++ b/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java @@ -110,7 +110,7 @@ public class DefaultRedisZSet extends AbstractRedisCollection implements R * @see org.springframework.data.redis.support.collections.RedisZSet#difference(org.springframework.data.redis.support.collections.RedisZSet) */ @Override - public Set difference(RedisZSet set) { + public Set diff(RedisZSet set) { return boundZSetOps.difference(set.getKey()); } @@ -119,7 +119,7 @@ public class DefaultRedisZSet extends AbstractRedisCollection implements R * @see org.springframework.data.redis.support.collections.RedisZSet#difference(java.util.Collection) */ @Override - public Set difference(Collection> sets) { + public Set diff(Collection> sets) { return boundZSetOps.difference(CollectionUtils.extractKeys(sets)); } @@ -128,7 +128,7 @@ public class DefaultRedisZSet extends AbstractRedisCollection implements R * @see org.springframework.data.redis.support.collections.RedisZSet#differenceWithScores(org.springframework.data.redis.support.collections.RedisZSet) */ @Override - public Set> differenceWithScores(RedisZSet set) { + public Set> diffWithScores(RedisZSet set) { return boundZSetOps.differenceWithScores(set.getKey()); } @@ -137,7 +137,7 @@ public class DefaultRedisZSet extends AbstractRedisCollection implements R * @see org.springframework.data.redis.support.collections.RedisZSet#differenceWithScores(java.util.Collection) */ @Override - public Set> differenceWithScores(Collection> sets) { + public Set> diffWithScores(Collection> sets) { return boundZSetOps.differenceWithScores(CollectionUtils.extractKeys(sets)); } @@ -146,7 +146,7 @@ public class DefaultRedisZSet extends AbstractRedisCollection implements R * @see org.springframework.data.redis.support.collections.RedisZSet#differenceAndStore(org.springframework.data.redis.support.collections.RedisZSet, java.lang.String) */ @Override - public RedisZSet differenceAndStore(RedisZSet set, String destKey) { + public RedisZSet 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 extends AbstractRedisCollection implements R * @see org.springframework.data.redis.support.collections.RedisZSet#differenceAndStore(java.util.Collection, java.lang.String) */ @Override - public RedisZSet differenceAndStore(Collection> sets, String destKey) { + public RedisZSet diffAndStore(Collection> sets, String destKey) { boundZSetOps.differenceAndStore(CollectionUtils.extractKeys(sets), destKey); return new DefaultRedisZSet<>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore()); diff --git a/src/main/java/org/springframework/data/redis/support/collections/RedisSet.java b/src/main/java/org/springframework/data/redis/support/collections/RedisSet.java index 48e043e2f..c08e3c664 100644 --- a/src/main/java/org/springframework/data/redis/support/collections/RedisSet.java +++ b/src/main/java/org/springframework/data/redis/support/collections/RedisSet.java @@ -27,28 +27,124 @@ import java.util.Set; */ public interface RedisSet extends RedisCollection, Set { + /** + * 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 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 intersect(Collection> 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 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 union(Collection> 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 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 diff(Collection> 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 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 intersectAndStore(Collection> 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 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 unionAndStore(Collection> 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 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 diffAndStore(Collection> sets, String destKey); /** diff --git a/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java b/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java index 09992c8d6..377b5660e 100644 --- a/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java +++ b/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java @@ -73,7 +73,7 @@ public interface RedisZSet extends RedisCollection, Set { * @return a {@link Set} containing the values that differ. * @since 2.6 */ - Set difference(RedisZSet set); + Set diff(RedisZSet set); /** * Diff this set and other {@link RedisZSet}s. @@ -82,7 +82,7 @@ public interface RedisZSet extends RedisCollection, Set { * @return a {@link Set} containing the values that differ. * @since 2.6 */ - Set difference(Collection> sets); + Set diff(Collection> sets); /** * Diff this set and another {@link RedisZSet}. @@ -91,16 +91,16 @@ public interface RedisZSet extends RedisCollection, Set { * @return a {@link Set} containing the values that differ with their scores. * @since 2.6 */ - Set> differenceWithScores(RedisZSet set); + Set> 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> differenceWithScores(Collection> sets); + Set> diffWithScores(Collection> 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 extends RedisCollection, Set { * @return a new {@link RedisZSet} pointing at {@code destKey}. * @since 2.6 */ - RedisZSet differenceAndStore(RedisZSet set, String destKey); + RedisZSet 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 extends RedisCollection, Set { * @return a new {@link RedisZSet} pointing at {@code destKey}. * @since 2.6 */ - RedisZSet differenceAndStore(Collection> sets, String destKey); + RedisZSet diffAndStore(Collection> sets, String destKey); /** * Intersect this set and another {@link RedisZSet}. @@ -154,7 +154,7 @@ public interface RedisZSet extends RedisCollection, Set { /** * 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 */ diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java index 26b08ab49..c648061de 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java @@ -633,8 +633,8 @@ public abstract class AbstractRedisZSetTestIntegration extends AbstractRedisC set2.add(t2, 2); set2.add(t3, 3); - assertThat(zSet.difference(Arrays.asList(set1, set2))).containsOnly(t1); - assertThat(zSet.differenceWithScores(Arrays.asList(set1, set2))).containsOnly(new DefaultTypedTuple<>(t1, 1d)); + assertThat(zSet.diff(Arrays.asList(set1, set2))).containsOnly(t1); + assertThat(zSet.diffWithScores(Arrays.asList(set1, set2))).containsOnly(new DefaultTypedTuple<>(t1, 1d)); } @ParameterizedRedisTest // GH-2041 @@ -658,7 +658,7 @@ public abstract class AbstractRedisZSetTestIntegration extends AbstractRedisC set2.add(t3, 3); String resultName = "test:zset:inter:result:1"; - RedisZSet diff = zSet.differenceAndStore(Arrays.asList(set1, set2), resultName); + RedisZSet diff = zSet.diffAndStore(Arrays.asList(set1, set2), resultName); assertThat(diff).containsOnly(t1); }