1818import java .util .List ;
1919import java .util .Map ;
2020
21- import org .jspecify .annotations .Nullable ;
21+ import org .jspecify .annotations .NonNull ;
22+ import org .jspecify .annotations .NullUnmarked ;
2223import org .springframework .data .domain .Range ;
2324import org .springframework .data .redis .connection .Limit ;
2425import org .springframework .data .redis .connection .RedisStreamCommands .XAddOptions ;
3637 * @author Dengliming
3738 * @since 2.2
3839 */
40+ @ NullUnmarked
3941public interface BoundStreamOperations <K , HK , HV > {
4042
4143 /**
@@ -46,8 +48,7 @@ public interface BoundStreamOperations<K, HK, HV> {
4648 * @return length of acknowledged records. {@literal null} when used in pipeline / transaction.
4749 * @see <a href="https://redis.io/commands/xack">Redis Documentation: XACK</a>
4850 */
49- @ Nullable
50- Long acknowledge (String group , String ... recordIds );
51+ Long acknowledge (@ NonNull String group , @ NonNull String @ NonNull ... recordIds );
5152
5253 /**
5354 * Append a record to the stream {@code key}.
@@ -56,8 +57,7 @@ public interface BoundStreamOperations<K, HK, HV> {
5657 * @return the record Id. {@literal null} when used in pipeline / transaction.
5758 * @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
5859 */
59- @ Nullable
60- RecordId add (Map <HK , HV > body );
60+ RecordId add (@ NonNull Map <@ NonNull HK , HV > body );
6161
6262 /**
6363 * Append a record to the stream {@code key} with the specified options.
@@ -68,8 +68,7 @@ public interface BoundStreamOperations<K, HK, HV> {
6868 * @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
6969 * @since 3.4
7070 */
71- @ Nullable
72- RecordId add (Map <HK , HV > content , XAddOptions xAddOptions );
71+ RecordId add (@ NonNull Map <@ NonNull HK , HV > content , @ NonNull XAddOptions xAddOptions );
7372
7473 /**
7574 * Removes the specified entries from the stream. Returns the number of items deleted, that may be different from the
@@ -79,8 +78,7 @@ public interface BoundStreamOperations<K, HK, HV> {
7978 * @return number of removed entries. {@literal null} when used in pipeline / transaction.
8079 * @see <a href="https://redis.io/commands/xdel">Redis Documentation: XDEL</a>
8180 */
82- @ Nullable
83- Long delete (String ... recordIds );
81+ Long delete (@ NonNull String @ NonNull ... recordIds );
8482
8583 /**
8684 * Create a consumer group.
@@ -89,34 +87,30 @@ public interface BoundStreamOperations<K, HK, HV> {
8987 * @param group name of the consumer group.
9088 * @return {@literal true} if successful. {@literal null} when used in pipeline / transaction.
9189 */
92- @ Nullable
93- String createGroup (ReadOffset readOffset , String group );
90+ String createGroup (@ NonNull ReadOffset readOffset , @ NonNull String group );
9491
9592 /**
9693 * Delete a consumer from a consumer group.
9794 *
9895 * @param consumer consumer identified by group name and consumer key.
9996 * @return {@literal true} if successful. {@literal null} when used in pipeline / transaction.
10097 */
101- @ Nullable
102- Boolean deleteConsumer (Consumer consumer );
98+ Boolean deleteConsumer (@ NonNull Consumer consumer );
10399
104100 /**
105101 * Destroy a consumer group.
106102 *
107103 * @param group name of the consumer group.
108104 * @return {@literal true} if successful. {@literal null} when used in pipeline / transaction.
109105 */
110- @ Nullable
111- Boolean destroyGroup (String group );
106+ Boolean destroyGroup (@ NonNull String group );
112107
113108 /**
114109 * Get the length of a stream.
115110 *
116111 * @return length of the stream. {@literal null} when used in pipeline / transaction.
117112 * @see <a href="https://redis.io/commands/xlen">Redis Documentation: XLEN</a>
118113 */
119- @ Nullable
120114 Long size ();
121115
122116 /**
@@ -126,7 +120,7 @@ public interface BoundStreamOperations<K, HK, HV> {
126120 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
127121 * @see <a href="https://redis.io/commands/xrange">Redis Documentation: XRANGE</a>
128122 */
129- default @ Nullable List <MapRecord <K , HK , HV >> range (Range <String > range ) {
123+ default List <@ NonNull MapRecord <K , HK , HV >> range (@ NonNull Range <String > range ) {
130124 return range (range , Limit .unlimited ());
131125 }
132126
@@ -138,8 +132,7 @@ public interface BoundStreamOperations<K, HK, HV> {
138132 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
139133 * @see <a href="https://redis.io/commands/xrange">Redis Documentation: XRANGE</a>
140134 */
141- @ Nullable
142- List <MapRecord <K , HK , HV >> range (Range <String > range , Limit limit );
135+ List <@ NonNull MapRecord <K , HK , HV >> range (@ NonNull Range <String > range , @ NonNull Limit limit );
143136
144137 /**
145138 * Read records from {@link ReadOffset}.
@@ -148,7 +141,7 @@ public interface BoundStreamOperations<K, HK, HV> {
148141 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
149142 * @see <a href="https://redis.io/commands/xread">Redis Documentation: XREAD</a>
150143 */
151- default @ Nullable List <MapRecord <K , HK , HV >> read (ReadOffset readOffset ) {
144+ default List <@ NonNull MapRecord <K , HK , HV >> read (@ NonNull ReadOffset readOffset ) {
152145 return read (StreamReadOptions .empty (), readOffset );
153146 }
154147
@@ -160,8 +153,7 @@ public interface BoundStreamOperations<K, HK, HV> {
160153 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
161154 * @see <a href="https://redis.io/commands/xread">Redis Documentation: XREAD</a>
162155 */
163- @ Nullable
164- List <MapRecord <K , HK , HV >> read (StreamReadOptions readOptions , ReadOffset readOffset );
156+ List <@ NonNull MapRecord <K , HK , HV >> read (@ NonNull StreamReadOptions readOptions , @ NonNull ReadOffset readOffset );
165157
166158 /**
167159 * Read records starting from {@link ReadOffset}. using a consumer group.
@@ -171,7 +163,7 @@ public interface BoundStreamOperations<K, HK, HV> {
171163 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
172164 * @see <a href="https://redis.io/commands/xreadgroup">Redis Documentation: XREADGROUP</a>
173165 */
174- default @ Nullable List <MapRecord <K , HK , HV >> read (Consumer consumer , ReadOffset readOffset ) {
166+ default List <@ NonNull MapRecord <K , HK , HV >> read (@ NonNull Consumer consumer , @ NonNull ReadOffset readOffset ) {
175167 return read (consumer , StreamReadOptions .empty (), readOffset );
176168 }
177169
@@ -184,8 +176,8 @@ public interface BoundStreamOperations<K, HK, HV> {
184176 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
185177 * @see <a href="https://redis.io/commands/xreadgroup">Redis Documentation: XREADGROUP</a>
186178 */
187- @ Nullable
188- List < MapRecord < K , HK , HV >> read ( Consumer consumer , StreamReadOptions readOptions , ReadOffset readOffset );
179+ List < @ NonNull MapRecord < K , HK , HV >> read ( @ NonNull Consumer consumer , @ NonNull StreamReadOptions readOptions ,
180+ @ NonNull ReadOffset readOffset );
189181
190182 /**
191183 * Read records from a stream within a specific {@link Range} in reverse order.
@@ -194,7 +186,7 @@ public interface BoundStreamOperations<K, HK, HV> {
194186 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
195187 * @see <a href="https://redis.io/commands/xrevrange">Redis Documentation: XREVRANGE</a>
196188 */
197- default @ Nullable List <MapRecord <K , HK , HV >> reverseRange (Range <String > range ) {
189+ default List <@ NonNull MapRecord <K , HK , HV >> reverseRange (@ NonNull Range <String > range ) {
198190 return reverseRange (range , Limit .unlimited ());
199191 }
200192
@@ -206,8 +198,7 @@ public interface BoundStreamOperations<K, HK, HV> {
206198 * @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
207199 * @see <a href="https://redis.io/commands/xrevrange">Redis Documentation: XREVRANGE</a>
208200 */
209- @ Nullable
210- List <MapRecord <K , HK , HV >> reverseRange (Range <String > range , Limit limit );
201+ List <@ NonNull MapRecord <K , HK , HV >> reverseRange (@ NonNull Range <String > range , @ NonNull Limit limit );
211202
212203 /**
213204 * Trims the stream to {@code count} elements.
@@ -216,7 +207,6 @@ public interface BoundStreamOperations<K, HK, HV> {
216207 * @return number of removed entries. {@literal null} when used in pipeline / transaction.
217208 * @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
218209 */
219- @ Nullable
220210 Long trim (long count );
221211
222212 /**
@@ -228,6 +218,5 @@ public interface BoundStreamOperations<K, HK, HV> {
228218 * @since 2.4
229219 * @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
230220 */
231- @ Nullable
232221 Long trim (long count , boolean approximateTrimming );
233222}
0 commit comments