2727 *
2828 * @author Mark Paluch
2929 * @author Christoph Strobl
30+ * @author John Blum
3031 * @since 2.0
3132 * @see RedisElementWriter
3233 * @see RedisElementReader
@@ -40,9 +41,8 @@ public interface RedisSerializationContext<K, V> {
4041 * @param <V> expected value type.
4142 * @return a new {@link RedisSerializationContextBuilder}.
4243 */
43- @ SuppressWarnings ("unchecked" )
4444 static <K , V > RedisSerializationContextBuilder <K , V > newSerializationContext () {
45- return new DefaultRedisSerializationContext .DefaultRedisSerializationContextBuilder ();
45+ return new DefaultRedisSerializationContext .DefaultRedisSerializationContextBuilder <> ();
4646 }
4747
4848 /**
@@ -68,7 +68,7 @@ static <K, V> RedisSerializationContextBuilder<K, V> newSerializationContext(Red
6868 * @param <V> expected value type.
6969 * @return a new {@link RedisSerializationContextBuilder}.
7070 */
71- @ SuppressWarnings (" unchecked" )
71+ @ SuppressWarnings ({ "rawtypes" , " unchecked" } )
7272 static <K , V > RedisSerializationContextBuilder <K , V > newSerializationContext (SerializationPair <?> serializationPair ) {
7373
7474 Assert .notNull (serializationPair , "SerializationPair must not be null!" );
@@ -114,7 +114,7 @@ static RedisSerializationContext<ByteBuffer, ByteBuffer> byteBuffer() {
114114 /**
115115 * Creates a new {@link RedisSerializationContext} using a {@link JdkSerializationRedisSerializer}.
116116 *
117- * @return new instance of {@link RedisSerializationContext}.
117+ * @return a new {@link RedisSerializationContext} using JDK Serializaton .
118118 * @since 2.1
119119 */
120120 static RedisSerializationContext <Object , Object > java () {
@@ -123,10 +123,11 @@ static RedisSerializationContext<Object, Object> java() {
123123
124124 /**
125125 * 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 .
127127 *
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.
130131 * @since 2.1
131132 */
132133 static RedisSerializationContext <Object , Object > java (ClassLoader classLoader ) {
@@ -136,7 +137,7 @@ static RedisSerializationContext<Object, Object> java(ClassLoader classLoader) {
136137 /**
137138 * Creates a new {@link RedisSerializationContext} using a {@link StringRedisSerializer}.
138139 *
139- * @return
140+ * @return a new {@link RedisSerializationContext} using a {@link StringRedisSerializer}.
140141 */
141142 static RedisSerializationContext <String , String > string () {
142143 return fromSerializer (RedisSerializer .string ());
@@ -145,9 +146,10 @@ static RedisSerializationContext<String, String> string() {
145146 /**
146147 * Creates a new {@link RedisSerializationContext} using the given {@link RedisSerializer}.
147148 *
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}.
151153 */
152154 static <T > RedisSerializationContext <T , T > fromSerializer (RedisSerializer <T > serializer ) {
153155 return just (SerializationPair .fromSerializer (serializer ));
@@ -156,9 +158,10 @@ static <T> RedisSerializationContext<T, T> fromSerializer(RedisSerializer<T> ser
156158 /**
157159 * Creates a new {@link RedisSerializationContext} using the given {@link SerializationPair}.
158160 *
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}.
162165 */
163166 static <T > RedisSerializationContext <T , T > just (SerializationPair <T > serializationPair ) {
164167 return RedisSerializationContext .<T , T > newSerializationContext (serializationPair ).build ();
@@ -278,10 +281,10 @@ default T read(ByteBuffer buffer) {
278281 RedisElementWriter <T > getWriter ();
279282
280283 /**
281- * Serialize a {@code element} to its {@link ByteBuffer} representation.
284+ * Serialize the given {@code element} to its {@link ByteBuffer} representation.
282285 *
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.
285288 */
286289 default ByteBuffer write (T element ) {
287290 return getWriter ().write (element );
@@ -314,6 +317,7 @@ interface RedisSerializationContextBuilder<K, V> {
314317 default RedisSerializationContextBuilder <K , V > key (RedisElementReader <K > reader , RedisElementWriter <K > writer ) {
315318
316319 key (SerializationPair .just (reader , writer ));
320+
317321 return this ;
318322 }
319323
@@ -326,6 +330,7 @@ default RedisSerializationContextBuilder<K, V> key(RedisElementReader<K> reader,
326330 default RedisSerializationContextBuilder <K , V > key (RedisSerializer <K > serializer ) {
327331
328332 key (SerializationPair .fromSerializer (serializer ));
333+
329334 return this ;
330335 }
331336
@@ -347,6 +352,7 @@ default RedisSerializationContextBuilder<K, V> key(RedisSerializer<K> serializer
347352 default RedisSerializationContextBuilder <K , V > value (RedisElementReader <V > reader , RedisElementWriter <V > writer ) {
348353
349354 value (SerializationPair .just (reader , writer ));
355+
350356 return this ;
351357 }
352358
@@ -359,6 +365,7 @@ default RedisSerializationContextBuilder<K, V> value(RedisElementReader<V> reade
359365 default RedisSerializationContextBuilder <K , V > value (RedisSerializer <V > serializer ) {
360366
361367 value (SerializationPair .fromSerializer (serializer ));
368+
362369 return this ;
363370 }
364371
@@ -377,10 +384,11 @@ default RedisSerializationContextBuilder<K, V> value(RedisSerializer<V> serializ
377384 * @param writer must not be {@literal null}.
378385 * @return {@literal this} builder.
379386 */
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 ) {
382389
383390 hashKey (SerializationPair .just (reader , writer ));
391+
384392 return this ;
385393 }
386394
@@ -390,9 +398,10 @@ default RedisSerializationContextBuilder<K, V> hashKey(RedisElementReader<? exte
390398 * @param serializer must not be {@literal null}.
391399 * @return {@literal this} builder.
392400 */
393- default RedisSerializationContextBuilder <K , V > hashKey (RedisSerializer <? extends Object > serializer ) {
401+ default RedisSerializationContextBuilder <K , V > hashKey (RedisSerializer <?> serializer ) {
394402
395403 hashKey (SerializationPair .fromSerializer (serializer ));
404+
396405 return this ;
397406 }
398407
@@ -411,10 +420,11 @@ default RedisSerializationContextBuilder<K, V> hashKey(RedisSerializer<? extends
411420 * @param writer must not be {@literal null}.
412421 * @return {@literal this} builder.
413422 */
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 ) {
416425
417426 hashValue (SerializationPair .just (reader , writer ));
427+
418428 return this ;
419429 }
420430
@@ -424,9 +434,10 @@ default RedisSerializationContextBuilder<K, V> hashValue(RedisElementReader<? ex
424434 * @param serializer must not be {@literal null}.
425435 * @return {@literal this} builder.
426436 */
427- default RedisSerializationContextBuilder <K , V > hashValue (RedisSerializer <? extends Object > serializer ) {
437+ default RedisSerializationContextBuilder <K , V > hashValue (RedisSerializer <?> serializer ) {
428438
429439 hashValue (SerializationPair .fromSerializer (serializer ));
440+
430441 return this ;
431442 }
432443
@@ -449,6 +460,7 @@ default RedisSerializationContextBuilder<K, V> string(RedisElementReader<String>
449460 RedisElementWriter <String > writer ) {
450461
451462 string (SerializationPair .just (reader , writer ));
463+
452464 return this ;
453465 }
454466
@@ -461,6 +473,7 @@ default RedisSerializationContextBuilder<K, V> string(RedisElementReader<String>
461473 default RedisSerializationContextBuilder <K , V > string (RedisSerializer <String > serializer ) {
462474
463475 string (SerializationPair .fromSerializer (serializer ));
476+
464477 return this ;
465478 }
466479
@@ -470,5 +483,6 @@ default RedisSerializationContextBuilder<K, V> string(RedisSerializer<String> se
470483 * @return the {@link RedisSerializationContext}.
471484 */
472485 RedisSerializationContext <K , V > build ();
486+
473487 }
474488}
0 commit comments