27
27
*
28
28
* @author Mark Paluch
29
29
* @author Christoph Strobl
30
+ * @author John Blum
30
31
* @since 2.0
31
32
* @see RedisElementWriter
32
33
* @see RedisElementReader
@@ -40,9 +41,8 @@ public interface RedisSerializationContext<K, V> {
40
41
* @param <V> expected value type.
41
42
* @return a new {@link RedisSerializationContextBuilder}.
42
43
*/
43
- @ SuppressWarnings ("unchecked" )
44
44
static <K , V > RedisSerializationContextBuilder <K , V > newSerializationContext () {
45
- return new DefaultRedisSerializationContext .DefaultRedisSerializationContextBuilder ();
45
+ return new DefaultRedisSerializationContext .DefaultRedisSerializationContextBuilder <> ();
46
46
}
47
47
48
48
/**
@@ -68,7 +68,7 @@ static <K, V> RedisSerializationContextBuilder<K, V> newSerializationContext(Red
68
68
* @param <V> expected value type.
69
69
* @return a new {@link RedisSerializationContextBuilder}.
70
70
*/
71
- @ SuppressWarnings (" unchecked" )
71
+ @ SuppressWarnings ({ "rawtypes" , " unchecked" } )
72
72
static <K , V > RedisSerializationContextBuilder <K , V > newSerializationContext (SerializationPair <?> serializationPair ) {
73
73
74
74
Assert .notNull (serializationPair , "SerializationPair must not be null" );
@@ -114,7 +114,7 @@ static RedisSerializationContext<ByteBuffer, ByteBuffer> byteBuffer() {
114
114
/**
115
115
* Creates a new {@link RedisSerializationContext} using a {@link JdkSerializationRedisSerializer}.
116
116
*
117
- * @return new instance of {@link RedisSerializationContext}.
117
+ * @return a new {@link RedisSerializationContext} using JDK Serializaton .
118
118
* @since 2.1
119
119
*/
120
120
static RedisSerializationContext <Object , Object > java () {
@@ -123,10 +123,11 @@ static RedisSerializationContext<Object, Object> java() {
123
123
124
124
/**
125
125
* Creates a new {@link RedisSerializationContext} using a {@link JdkSerializationRedisSerializer} with given
126
- * {@link ClassLoader}.
126
+ * {@link ClassLoader} to resolves {@link Class type} of the keys and values stored in Redis .
127
127
*
128
- * @param classLoader the {@link ClassLoader} to use for deserialization. Can be {@literal null}.
129
- * @return new instance of {@link RedisSerializationContext}.
128
+ * @param classLoader {@link ClassLoader} used to resolve {@link Class types} of keys and value stored in Redis
129
+ * during deserialization; can be {@literal null}.
130
+ * @return a new {@link RedisSerializationContext} using JDK Serializaton.
130
131
* @since 2.1
131
132
*/
132
133
static RedisSerializationContext <Object , Object > java (ClassLoader classLoader ) {
@@ -136,7 +137,7 @@ static RedisSerializationContext<Object, Object> java(ClassLoader classLoader) {
136
137
/**
137
138
* Creates a new {@link RedisSerializationContext} using a {@link StringRedisSerializer}.
138
139
*
139
- * @return
140
+ * @return a new {@link RedisSerializationContext} using a {@link StringRedisSerializer}.
140
141
*/
141
142
static RedisSerializationContext <String , String > string () {
142
143
return fromSerializer (RedisSerializer .string ());
@@ -145,9 +146,10 @@ static RedisSerializationContext<String, String> string() {
145
146
/**
146
147
* Creates a new {@link RedisSerializationContext} using the given {@link RedisSerializer}.
147
148
*
148
- * @param serializer must not be {@literal null}.
149
- * @param <T>
150
- * @return
149
+ * @param <T> {@link Class Type} of {@link Object} being de/serialized by the {@link RedisSerializer}.
150
+ * @param serializer {@link RedisSerializer} used to de/serialize keys and value stored in Redis;
151
+ * must not be {@literal null}.
152
+ * @return a new {@link RedisSerializationContext} using the given {@link RedisSerializer}.
151
153
*/
152
154
static <T > RedisSerializationContext <T , T > fromSerializer (RedisSerializer <T > serializer ) {
153
155
return just (SerializationPair .fromSerializer (serializer ));
@@ -156,9 +158,10 @@ static <T> RedisSerializationContext<T, T> fromSerializer(RedisSerializer<T> ser
156
158
/**
157
159
* Creates a new {@link RedisSerializationContext} using the given {@link SerializationPair}.
158
160
*
159
- * @param serializationPair
160
- * @param <T>
161
- * @return
161
+ * @param <T> {@link Class Type} of {@link Object} de/serialized by the {@link SerializationPair}.
162
+ * @param serializationPair {@link SerializationPair} used to de/serialize keys and values stored in Redis;
163
+ * must not be {@literal null}.
164
+ * @return a new {@link RedisSerializationContext} using the given {@link SerializationPair}.
162
165
*/
163
166
static <T > RedisSerializationContext <T , T > just (SerializationPair <T > serializationPair ) {
164
167
return RedisSerializationContext .<T , T > newSerializationContext (serializationPair ).build ();
@@ -278,10 +281,10 @@ default T read(ByteBuffer buffer) {
278
281
RedisElementWriter <T > getWriter ();
279
282
280
283
/**
281
- * Serialize a {@code element} to its {@link ByteBuffer} representation.
284
+ * Serialize the given {@code element} to its {@link ByteBuffer} representation.
282
285
*
283
- * @param element
284
- * @return the {@link ByteBuffer} representing {@code element} in its binary form.
286
+ * @param element {@link Object} to write (serialize) as a stream of bytes.
287
+ * @return the {@link ByteBuffer} representing the given {@code element} in binary form.
285
288
*/
286
289
default ByteBuffer write (T element ) {
287
290
return getWriter ().write (element );
@@ -314,6 +317,7 @@ interface RedisSerializationContextBuilder<K, V> {
314
317
default RedisSerializationContextBuilder <K , V > key (RedisElementReader <K > reader , RedisElementWriter <K > writer ) {
315
318
316
319
key (SerializationPair .just (reader , writer ));
320
+
317
321
return this ;
318
322
}
319
323
@@ -326,6 +330,7 @@ default RedisSerializationContextBuilder<K, V> key(RedisElementReader<K> reader,
326
330
default RedisSerializationContextBuilder <K , V > key (RedisSerializer <K > serializer ) {
327
331
328
332
key (SerializationPair .fromSerializer (serializer ));
333
+
329
334
return this ;
330
335
}
331
336
@@ -347,6 +352,7 @@ default RedisSerializationContextBuilder<K, V> key(RedisSerializer<K> serializer
347
352
default RedisSerializationContextBuilder <K , V > value (RedisElementReader <V > reader , RedisElementWriter <V > writer ) {
348
353
349
354
value (SerializationPair .just (reader , writer ));
355
+
350
356
return this ;
351
357
}
352
358
@@ -359,6 +365,7 @@ default RedisSerializationContextBuilder<K, V> value(RedisElementReader<V> reade
359
365
default RedisSerializationContextBuilder <K , V > value (RedisSerializer <V > serializer ) {
360
366
361
367
value (SerializationPair .fromSerializer (serializer ));
368
+
362
369
return this ;
363
370
}
364
371
@@ -377,10 +384,11 @@ default RedisSerializationContextBuilder<K, V> value(RedisSerializer<V> serializ
377
384
* @param writer must not be {@literal null}.
378
385
* @return {@literal this} builder.
379
386
*/
380
- default RedisSerializationContextBuilder <K , V > hashKey (RedisElementReader <? extends Object > reader ,
381
- RedisElementWriter <? extends Object > writer ) {
387
+ default RedisSerializationContextBuilder <K , V > hashKey (RedisElementReader <?> reader ,
388
+ RedisElementWriter <?> writer ) {
382
389
383
390
hashKey (SerializationPair .just (reader , writer ));
391
+
384
392
return this ;
385
393
}
386
394
@@ -390,9 +398,10 @@ default RedisSerializationContextBuilder<K, V> hashKey(RedisElementReader<? exte
390
398
* @param serializer must not be {@literal null}.
391
399
* @return {@literal this} builder.
392
400
*/
393
- default RedisSerializationContextBuilder <K , V > hashKey (RedisSerializer <? extends Object > serializer ) {
401
+ default RedisSerializationContextBuilder <K , V > hashKey (RedisSerializer <?> serializer ) {
394
402
395
403
hashKey (SerializationPair .fromSerializer (serializer ));
404
+
396
405
return this ;
397
406
}
398
407
@@ -411,10 +420,11 @@ default RedisSerializationContextBuilder<K, V> hashKey(RedisSerializer<? extends
411
420
* @param writer must not be {@literal null}.
412
421
* @return {@literal this} builder.
413
422
*/
414
- default RedisSerializationContextBuilder <K , V > hashValue (RedisElementReader <? extends Object > reader ,
415
- RedisElementWriter <? extends Object > writer ) {
423
+ default RedisSerializationContextBuilder <K , V > hashValue (RedisElementReader <?> reader ,
424
+ RedisElementWriter <?> writer ) {
416
425
417
426
hashValue (SerializationPair .just (reader , writer ));
427
+
418
428
return this ;
419
429
}
420
430
@@ -424,9 +434,10 @@ default RedisSerializationContextBuilder<K, V> hashValue(RedisElementReader<? ex
424
434
* @param serializer must not be {@literal null}.
425
435
* @return {@literal this} builder.
426
436
*/
427
- default RedisSerializationContextBuilder <K , V > hashValue (RedisSerializer <? extends Object > serializer ) {
437
+ default RedisSerializationContextBuilder <K , V > hashValue (RedisSerializer <?> serializer ) {
428
438
429
439
hashValue (SerializationPair .fromSerializer (serializer ));
440
+
430
441
return this ;
431
442
}
432
443
@@ -449,6 +460,7 @@ default RedisSerializationContextBuilder<K, V> string(RedisElementReader<String>
449
460
RedisElementWriter <String > writer ) {
450
461
451
462
string (SerializationPair .just (reader , writer ));
463
+
452
464
return this ;
453
465
}
454
466
@@ -461,6 +473,7 @@ default RedisSerializationContextBuilder<K, V> string(RedisElementReader<String>
461
473
default RedisSerializationContextBuilder <K , V > string (RedisSerializer <String > serializer ) {
462
474
463
475
string (SerializationPair .fromSerializer (serializer ));
476
+
464
477
return this ;
465
478
}
466
479
@@ -470,5 +483,6 @@ default RedisSerializationContextBuilder<K, V> string(RedisSerializer<String> se
470
483
* @return the {@link RedisSerializationContext}.
471
484
*/
472
485
RedisSerializationContext <K , V > build ();
486
+
473
487
}
474
488
}
0 commit comments