18
18
import java .util .List ;
19
19
import java .util .Map ;
20
20
21
- import org .jspecify .annotations .Nullable ;
21
+ import org .jspecify .annotations .NonNull ;
22
+ import org .jspecify .annotations .NullUnmarked ;
22
23
import org .springframework .data .domain .Range ;
23
24
import org .springframework .data .redis .connection .Limit ;
24
25
import org .springframework .data .redis .connection .RedisStreamCommands .XAddOptions ;
36
37
* @author Dengliming
37
38
* @since 2.2
38
39
*/
40
+ @ NullUnmarked
39
41
public interface BoundStreamOperations <K , HK , HV > {
40
42
41
43
/**
@@ -46,8 +48,7 @@ public interface BoundStreamOperations<K, HK, HV> {
46
48
* @return length of acknowledged records. {@literal null} when used in pipeline / transaction.
47
49
* @see <a href="https://redis.io/commands/xack">Redis Documentation: XACK</a>
48
50
*/
49
- @ Nullable
50
- Long acknowledge (String group , String ... recordIds );
51
+ Long acknowledge (@ NonNull String group , @ NonNull String @ NonNull ... recordIds );
51
52
52
53
/**
53
54
* Append a record to the stream {@code key}.
@@ -56,8 +57,7 @@ public interface BoundStreamOperations<K, HK, HV> {
56
57
* @return the record Id. {@literal null} when used in pipeline / transaction.
57
58
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
58
59
*/
59
- @ Nullable
60
- RecordId add (Map <HK , HV > body );
60
+ RecordId add (@ NonNull Map <@ NonNull HK , HV > body );
61
61
62
62
/**
63
63
* Append a record to the stream {@code key} with the specified options.
@@ -68,8 +68,7 @@ public interface BoundStreamOperations<K, HK, HV> {
68
68
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
69
69
* @since 3.4
70
70
*/
71
- @ Nullable
72
- RecordId add (Map <HK , HV > content , XAddOptions xAddOptions );
71
+ RecordId add (@ NonNull Map <@ NonNull HK , HV > content , @ NonNull XAddOptions xAddOptions );
73
72
74
73
/**
75
74
* 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> {
79
78
* @return number of removed entries. {@literal null} when used in pipeline / transaction.
80
79
* @see <a href="https://redis.io/commands/xdel">Redis Documentation: XDEL</a>
81
80
*/
82
- @ Nullable
83
- Long delete (String ... recordIds );
81
+ Long delete (@ NonNull String @ NonNull ... recordIds );
84
82
85
83
/**
86
84
* Create a consumer group.
@@ -89,34 +87,30 @@ public interface BoundStreamOperations<K, HK, HV> {
89
87
* @param group name of the consumer group.
90
88
* @return {@literal true} if successful. {@literal null} when used in pipeline / transaction.
91
89
*/
92
- @ Nullable
93
- String createGroup (ReadOffset readOffset , String group );
90
+ String createGroup (@ NonNull ReadOffset readOffset , @ NonNull String group );
94
91
95
92
/**
96
93
* Delete a consumer from a consumer group.
97
94
*
98
95
* @param consumer consumer identified by group name and consumer key.
99
96
* @return {@literal true} if successful. {@literal null} when used in pipeline / transaction.
100
97
*/
101
- @ Nullable
102
- Boolean deleteConsumer (Consumer consumer );
98
+ Boolean deleteConsumer (@ NonNull Consumer consumer );
103
99
104
100
/**
105
101
* Destroy a consumer group.
106
102
*
107
103
* @param group name of the consumer group.
108
104
* @return {@literal true} if successful. {@literal null} when used in pipeline / transaction.
109
105
*/
110
- @ Nullable
111
- Boolean destroyGroup (String group );
106
+ Boolean destroyGroup (@ NonNull String group );
112
107
113
108
/**
114
109
* Get the length of a stream.
115
110
*
116
111
* @return length of the stream. {@literal null} when used in pipeline / transaction.
117
112
* @see <a href="https://redis.io/commands/xlen">Redis Documentation: XLEN</a>
118
113
*/
119
- @ Nullable
120
114
Long size ();
121
115
122
116
/**
@@ -126,7 +120,7 @@ public interface BoundStreamOperations<K, HK, HV> {
126
120
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
127
121
* @see <a href="https://redis.io/commands/xrange">Redis Documentation: XRANGE</a>
128
122
*/
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 ) {
130
124
return range (range , Limit .unlimited ());
131
125
}
132
126
@@ -138,8 +132,7 @@ public interface BoundStreamOperations<K, HK, HV> {
138
132
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
139
133
* @see <a href="https://redis.io/commands/xrange">Redis Documentation: XRANGE</a>
140
134
*/
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 );
143
136
144
137
/**
145
138
* Read records from {@link ReadOffset}.
@@ -148,7 +141,7 @@ public interface BoundStreamOperations<K, HK, HV> {
148
141
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
149
142
* @see <a href="https://redis.io/commands/xread">Redis Documentation: XREAD</a>
150
143
*/
151
- default @ Nullable List <MapRecord <K , HK , HV >> read (ReadOffset readOffset ) {
144
+ default List <@ NonNull MapRecord <K , HK , HV >> read (@ NonNull ReadOffset readOffset ) {
152
145
return read (StreamReadOptions .empty (), readOffset );
153
146
}
154
147
@@ -160,8 +153,7 @@ public interface BoundStreamOperations<K, HK, HV> {
160
153
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
161
154
* @see <a href="https://redis.io/commands/xread">Redis Documentation: XREAD</a>
162
155
*/
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 );
165
157
166
158
/**
167
159
* Read records starting from {@link ReadOffset}. using a consumer group.
@@ -171,7 +163,7 @@ public interface BoundStreamOperations<K, HK, HV> {
171
163
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
172
164
* @see <a href="https://redis.io/commands/xreadgroup">Redis Documentation: XREADGROUP</a>
173
165
*/
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 ) {
175
167
return read (consumer , StreamReadOptions .empty (), readOffset );
176
168
}
177
169
@@ -184,8 +176,8 @@ public interface BoundStreamOperations<K, HK, HV> {
184
176
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
185
177
* @see <a href="https://redis.io/commands/xreadgroup">Redis Documentation: XREADGROUP</a>
186
178
*/
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 );
189
181
190
182
/**
191
183
* Read records from a stream within a specific {@link Range} in reverse order.
@@ -194,7 +186,7 @@ public interface BoundStreamOperations<K, HK, HV> {
194
186
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
195
187
* @see <a href="https://redis.io/commands/xrevrange">Redis Documentation: XREVRANGE</a>
196
188
*/
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 ) {
198
190
return reverseRange (range , Limit .unlimited ());
199
191
}
200
192
@@ -206,8 +198,7 @@ public interface BoundStreamOperations<K, HK, HV> {
206
198
* @return list with members of the resulting stream. {@literal null} when used in pipeline / transaction.
207
199
* @see <a href="https://redis.io/commands/xrevrange">Redis Documentation: XREVRANGE</a>
208
200
*/
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 );
211
202
212
203
/**
213
204
* Trims the stream to {@code count} elements.
@@ -216,7 +207,6 @@ public interface BoundStreamOperations<K, HK, HV> {
216
207
* @return number of removed entries. {@literal null} when used in pipeline / transaction.
217
208
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
218
209
*/
219
- @ Nullable
220
210
Long trim (long count );
221
211
222
212
/**
@@ -228,6 +218,5 @@ public interface BoundStreamOperations<K, HK, HV> {
228
218
* @since 2.4
229
219
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
230
220
*/
231
- @ Nullable
232
221
Long trim (long count , boolean approximateTrimming );
233
222
}
0 commit comments