3838 *
3939 * @author Mark Paluch
4040 * @author Christoph Strobl
41+ * @author John Blum
4142 * @since 2.0
4243 */
4344class DefaultReactiveHashOperations <H , HK , HV > implements ReactiveHashOperations <H , HK , HV > {
@@ -62,7 +63,8 @@ public Mono<Long> remove(H key, Object... hashKeys) {
6263 Assert .noNullElements (hashKeys , "Hash keys must not contain null elements" );
6364
6465 return createMono (hashCommands -> Flux .fromArray (hashKeys ) //
65- .map (o -> (HK ) o ).map (this ::rawHashKey ) //
66+ .map (hashKey -> (HK ) hashKey )
67+ .map (this ::rawHashKey ) //
6668 .collectList () //
6769 .flatMap (hks -> hashCommands .hDel (rawKey (key ), hks )));
6870 }
@@ -84,8 +86,8 @@ public Mono<HV> get(H key, Object hashKey) {
8486 Assert .notNull (key , "Key must not be null" );
8587 Assert .notNull (hashKey , "Hash key must not be null" );
8688
87- return createMono (hashCommands ->
88- hashCommands . hGet ( rawKey ( key ), rawHashKey (( HK ) hashKey )) .map (this ::readHashValue ));
89+ return createMono (hashCommands -> hashCommands . hGet ( rawKey ( key ), rawHashKey (( HK ) hashKey ))
90+ .map (this ::readHashValue ));
8991 }
9092
9193 @ Override
@@ -107,8 +109,7 @@ public Mono<Long> increment(H key, HK hashKey, long delta) {
107109 Assert .notNull (key , "Key must not be null" );
108110 Assert .notNull (hashKey , "Hash key must not be null" );
109111
110- return template .doCreateMono (connection -> connection //
111- .numberCommands () //
112+ return template .doCreateMono (connection -> connection .numberCommands ()
112113 .hIncrBy (rawKey (key ), rawHashKey (hashKey ), delta ));
113114 }
114115
@@ -118,8 +119,7 @@ public Mono<Double> increment(H key, HK hashKey, double delta) {
118119 Assert .notNull (key , "Key must not be null" );
119120 Assert .notNull (hashKey , "Hash key must not be null" );
120121
121- return template .doCreateMono (connection -> connection //
122- .numberCommands () //
122+ return template .doCreateMono (connection -> connection .numberCommands ()
123123 .hIncrBy (rawKey (key ), rawHashKey (hashKey ), delta ));
124124 }
125125
@@ -128,34 +128,35 @@ public Mono<HK> randomKey(H key) {
128128
129129 Assert .notNull (key , "Key must not be null" );
130130
131- return template .doCreateMono (connection -> connection //
132- .hashCommands (). hRandField ( rawKey ( key ))). map (this ::readRequiredHashKey );
131+ return template .doCreateMono (connection -> connection . hashCommands (). hRandField ( rawKey ( key )))
132+ .map (this ::readRequiredHashKey );
133133 }
134134
135135 @ Override
136136 public Mono <Map .Entry <HK , HV >> randomEntry (H key ) {
137137
138138 Assert .notNull (key , "Key must not be null" );
139139
140- return createMono (hashCommands ->hashCommands .hRandFieldWithValues (rawKey (key ))).map (this ::deserializeHashEntry );
140+ return createMono (hashCommands -> hashCommands .hRandFieldWithValues (rawKey (key )))
141+ .map (this ::deserializeHashEntry );
141142 }
142143
143144 @ Override
144145 public Flux <HK > randomKeys (H key , long count ) {
145146
146147 Assert .notNull (key , "Key must not be null" );
147148
148- return template .doCreateFlux (connection -> connection //
149- .hashCommands (). hRandField ( rawKey ( key ), count )). map (this ::readRequiredHashKey );
149+ return template .doCreateFlux (connection -> connection . hashCommands (). hRandField ( rawKey ( key ), count ))
150+ .map (this ::readRequiredHashKey );
150151 }
151152
152153 @ Override
153154 public Flux <Map .Entry <HK , HV >> randomEntries (H key , long count ) {
154155
155156 Assert .notNull (key , "Key must not be null" );
156157
157- return template .doCreateFlux (connection -> connection //
158- .hashCommands (). hRandFieldWithValues ( rawKey ( key ), count )). map (this ::deserializeHashEntry );
158+ return template .doCreateFlux (connection -> connection . hashCommands (). hRandFieldWithValues ( rawKey ( key ), count ))
159+ .map (this ::deserializeHashEntry );
159160 }
160161
161162 @ Override
@@ -211,7 +212,7 @@ public Flux<HV> values(H key) {
211212
212213 Assert .notNull (key , "Key must not be null" );
213214
214- return createFlux (connection -> connection .hVals (rawKey (key )) //
215+ return createFlux (hashCommands -> hashCommands .hVals (rawKey (key )) //
215216 .map (this ::readRequiredHashValue ));
216217 }
217218
@@ -278,28 +279,28 @@ private HK readRequiredHashKey(ByteBuffer buffer) {
278279
279280 HK hashKey = readHashKey (buffer );
280281
281- if (hashKey = = null ) {
282- throw new InvalidDataAccessApiUsageException ( "Deserialized hash key is null" ) ;
282+ if (hashKey ! = null ) {
283+ return hashKey ;
283284 }
284285
285- return hashKey ;
286+ throw new InvalidDataAccessApiUsageException ( "Deserialized hash key is null" ) ;
286287 }
287288
288289 @ SuppressWarnings ("unchecked" )
289290 @ Nullable
290291 private HV readHashValue (@ Nullable ByteBuffer value ) {
291- return ( HV ) ( value == null ? null : serializationContext .getHashValueSerializationPair ().read (value )) ;
292+ return value != null ? ( HV ) serializationContext .getHashValueSerializationPair ().read (value ) : null ;
292293 }
293294
294295 private HV readRequiredHashValue (ByteBuffer buffer ) {
295296
296297 HV hashValue = readHashValue (buffer );
297298
298- if (hashValue = = null ) {
299- throw new InvalidDataAccessApiUsageException ( "Deserialized hash value is null" ) ;
299+ if (hashValue ! = null ) {
300+ return hashValue ;
300301 }
301302
302- return hashValue ;
303+ throw new InvalidDataAccessApiUsageException ( "Deserialized hash value is null" ) ;
303304 }
304305
305306 private Map .Entry <HK , HV > deserializeHashEntry (Map .Entry <ByteBuffer , ByteBuffer > source ) {
@@ -309,9 +310,11 @@ private Map.Entry<HK, HV> deserializeHashEntry(Map.Entry<ByteBuffer, ByteBuffer>
309310 private List <HV > deserializeHashValues (List <ByteBuffer > source ) {
310311
311312 List <HV > values = new ArrayList <>(source .size ());
313+
312314 for (ByteBuffer byteBuffer : source ) {
313315 values .add (readHashValue (byteBuffer ));
314316 }
317+
315318 return values ;
316319 }
317320}
0 commit comments