|
19 | 19 | import java.util.Iterator;
|
20 | 20 | import java.util.Set;
|
21 | 21 |
|
| 22 | +import org.springframework.data.redis.core.RedisOperations; |
| 23 | + |
22 | 24 | /**
|
23 | 25 | * Redis extension for the {@link Set} contract. Supports {@link Set} specific operations backed by Redis operations.
|
24 | 26 | *
|
25 | 27 | * @author Costin Leau
|
26 | 28 | * @author Christoph Strobl
|
| 29 | + * @author Mark Paluch |
27 | 30 | */
|
28 | 31 | public interface RedisSet<E> extends RedisCollection<E>, Set<E> {
|
29 | 32 |
|
30 |
| - Set<E> intersect(RedisSet<?> set); |
| 33 | + /** |
| 34 | + * Constructs a new {@link RedisSet} instance. |
| 35 | + * |
| 36 | + * @param key Redis key of this set. |
| 37 | + * @param operations {@link RedisOperations} for the value type of this set. |
| 38 | + * @since 2.6 |
| 39 | + */ |
| 40 | + static <E> RedisSet<E> create(String key, RedisOperations<String, E> operations) { |
| 41 | + return new DefaultRedisSet<>(key, operations); |
| 42 | + } |
31 | 43 |
|
32 |
| - Set<E> intersect(Collection<? extends RedisSet<?>> sets); |
| 44 | + /** |
| 45 | + * Diff this set and another {@link RedisSet}. |
| 46 | + * |
| 47 | + * @param set must not be {@literal null}. |
| 48 | + * @return a {@link Set} containing the values that differ. |
| 49 | + */ |
| 50 | + Set<E> diff(RedisSet<?> set); |
33 | 51 |
|
34 |
| - Set<E> union(RedisSet<?> set); |
| 52 | + /** |
| 53 | + * Diff this set and other {@link RedisSet}s. |
| 54 | + * |
| 55 | + * @param sets must not be {@literal null}. |
| 56 | + * @return a {@link Set} containing the values that differ. |
| 57 | + */ |
| 58 | + Set<E> diff(Collection<? extends RedisSet<?>> sets); |
35 | 59 |
|
36 |
| - Set<E> union(Collection<? extends RedisSet<?>> sets); |
| 60 | + /** |
| 61 | + * Create a new {@link RedisSet} by diffing this set and {@link RedisSet} and store result in destination |
| 62 | + * {@code destKey}. |
| 63 | + * |
| 64 | + * @param set must not be {@literal null}. |
| 65 | + * @param destKey must not be {@literal null}. |
| 66 | + * @return a new {@link RedisSet} pointing at {@code destKey}. |
| 67 | + */ |
| 68 | + RedisSet<E> diffAndStore(RedisSet<?> set, String destKey); |
37 | 69 |
|
38 |
| - Set<E> diff(RedisSet<?> set); |
| 70 | + /** |
| 71 | + * Create a new {@link RedisSet} by diffing this set and the collection {@link RedisSet} and store result in |
| 72 | + * destination {@code destKey}. |
| 73 | + * |
| 74 | + * @param sets must not be {@literal null}. |
| 75 | + * @param destKey must not be {@literal null}. |
| 76 | + * @return a new {@link RedisSet} pointing at {@code destKey}. |
| 77 | + */ |
| 78 | + RedisSet<E> diffAndStore(Collection<? extends RedisSet<?>> sets, String destKey); |
39 | 79 |
|
40 |
| - Set<E> diff(Collection<? extends RedisSet<?>> sets); |
| 80 | + /** |
| 81 | + * Intersect this set and another {@link RedisSet}. |
| 82 | + * |
| 83 | + * @param set must not be {@literal null}. |
| 84 | + * @return a {@link Set} containing the intersecting values. |
| 85 | + */ |
| 86 | + Set<E> intersect(RedisSet<?> set); |
41 | 87 |
|
| 88 | + /** |
| 89 | + * Intersect this set and other {@link RedisSet}s. |
| 90 | + * |
| 91 | + * @param sets must not be {@literal null}. |
| 92 | + * @return a {@link Set} containing the intersecting values. |
| 93 | + */ |
| 94 | + Set<E> intersect(Collection<? extends RedisSet<?>> sets); |
| 95 | + |
| 96 | + /** |
| 97 | + * Create a new {@link RedisSet} by intersecting this set and {@link RedisSet} and store result in destination |
| 98 | + * {@code destKey}. |
| 99 | + * |
| 100 | + * @param set must not be {@literal null}. |
| 101 | + * @param destKey must not be {@literal null}. |
| 102 | + * @return a new {@link RedisSet} pointing at {@code destKey} |
| 103 | + */ |
42 | 104 | RedisSet<E> intersectAndStore(RedisSet<?> set, String destKey);
|
43 | 105 |
|
| 106 | + /** |
| 107 | + * Create a new {@link RedisSet} by intersecting this set and the collection {@link RedisSet} and store result in |
| 108 | + * destination {@code destKey}. |
| 109 | + * |
| 110 | + * @param sets must not be {@literal null}. |
| 111 | + * @param destKey must not be {@literal null}. |
| 112 | + * @return a new {@link RedisSet} pointing at {@code destKey} |
| 113 | + */ |
44 | 114 | RedisSet<E> intersectAndStore(Collection<? extends RedisSet<?>> sets, String destKey);
|
45 | 115 |
|
46 |
| - RedisSet<E> unionAndStore(RedisSet<?> set, String destKey); |
| 116 | + /** |
| 117 | + * Union this set and another {@link RedisSet}. |
| 118 | + * |
| 119 | + * @param set must not be {@literal null}. |
| 120 | + * @return a {@link Set} containing the combined values. |
| 121 | + */ |
| 122 | + Set<E> union(RedisSet<?> set); |
47 | 123 |
|
48 |
| - RedisSet<E> unionAndStore(Collection<? extends RedisSet<?>> sets, String destKey); |
| 124 | + /** |
| 125 | + * Union this set and other {@link RedisSet}s. |
| 126 | + * |
| 127 | + * @param sets must not be {@literal null}. |
| 128 | + * @return a {@link Set} containing the combined values. |
| 129 | + */ |
| 130 | + Set<E> union(Collection<? extends RedisSet<?>> sets); |
49 | 131 |
|
50 |
| - RedisSet<E> diffAndStore(RedisSet<?> set, String destKey); |
| 132 | + /** |
| 133 | + * Create a new {@link RedisSet} by union this set and {@link RedisSet} and store result in destination |
| 134 | + * {@code destKey}. |
| 135 | + * |
| 136 | + * @param set must not be {@literal null}. |
| 137 | + * @param destKey must not be {@literal null}. |
| 138 | + * @return a new {@link RedisSet} pointing at {@code destKey} |
| 139 | + */ |
| 140 | + RedisSet<E> unionAndStore(RedisSet<?> set, String destKey); |
51 | 141 |
|
52 |
| - RedisSet<E> diffAndStore(Collection<? extends RedisSet<?>> sets, String destKey); |
| 142 | + /** |
| 143 | + * Create a new {@link RedisSet} by union this set and the collection {@link RedisSet} and store result in destination |
| 144 | + * {@code destKey}. |
| 145 | + * |
| 146 | + * @param sets must not be {@literal null}. |
| 147 | + * @param destKey must not be {@literal null}. |
| 148 | + * @return a new {@link RedisSet} pointing at {@code destKey} |
| 149 | + */ |
| 150 | + RedisSet<E> unionAndStore(Collection<? extends RedisSet<?>> sets, String destKey); |
53 | 151 |
|
54 | 152 | /**
|
55 | 153 | * @since 1.4
|
|
0 commit comments