Skip to content

Commit c7ded60

Browse files
jxblummp911de
authored andcommitted
Rename Function Lambda parameter to match command interface in (Default) ReactiveXxxOperations.
Cleanup compiler warning. Fix unnatural line breaks. Closes #2658 Original pull request: #2659
1 parent 07ce475 commit c7ded60

8 files changed

+278
-255
lines changed

src/main/java/org/springframework/data/redis/core/DefaultReactiveGeoOperations.java

+25-25
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Mono<Long> add(K key, Point point, V member) {
6868
Assert.notNull(point, "Point must not be null");
6969
Assert.notNull(member, "Member must not be null");
7070

71-
return createMono(connection -> connection.geoAdd(rawKey(key), point, rawValue(member)));
71+
return createMono(geoCommands -> geoCommands.geoAdd(rawKey(key), point, rawValue(member)));
7272
}
7373

7474
@Override
@@ -77,7 +77,7 @@ public Mono<Long> add(K key, GeoLocation<V> location) {
7777
Assert.notNull(key, "Key must not be null");
7878
Assert.notNull(location, "GeoLocation must not be null");
7979

80-
return createMono(connection -> connection.geoAdd(rawKey(key),
80+
return createMono(geoCommands -> geoCommands.geoAdd(rawKey(key),
8181
new GeoLocation<>(rawValue(location.getName()), location.getPoint())));
8282
}
8383

@@ -87,13 +87,13 @@ public Mono<Long> add(K key, Map<V, Point> memberCoordinateMap) {
8787
Assert.notNull(key, "Key must not be null");
8888
Assert.notNull(memberCoordinateMap, "MemberCoordinateMap must not be null");
8989

90-
return createMono(connection -> {
90+
return createMono(geoCommands -> {
9191

9292
Mono<List<GeoLocation<ByteBuffer>>> serializedList = Flux
9393
.fromIterable(() -> memberCoordinateMap.entrySet().iterator())
9494
.map(entry -> new GeoLocation<>(rawValue(entry.getKey()), entry.getValue())).collectList();
9595

96-
return serializedList.flatMap(list -> connection.geoAdd(rawKey(key), list));
96+
return serializedList.flatMap(list -> geoCommands.geoAdd(rawKey(key), list));
9797
});
9898
}
9999

@@ -103,12 +103,12 @@ public Mono<Long> add(K key, Iterable<GeoLocation<V>> geoLocations) {
103103
Assert.notNull(key, "Key must not be null");
104104
Assert.notNull(geoLocations, "GeoLocations must not be null");
105105

106-
return createMono(connection -> {
106+
return createMono(geoCommands -> {
107107

108108
Mono<List<GeoLocation<ByteBuffer>>> serializedList = Flux.fromIterable(geoLocations)
109109
.map(location -> new GeoLocation<>(rawValue(location.getName()), location.getPoint())).collectList();
110110

111-
return serializedList.flatMap(list -> connection.geoAdd(rawKey(key), list));
111+
return serializedList.flatMap(list -> geoCommands.geoAdd(rawKey(key), list));
112112
});
113113
}
114114

@@ -118,11 +118,11 @@ public Flux<Long> add(K key, Publisher<? extends Collection<GeoLocation<V>>> loc
118118
Assert.notNull(key, "Key must not be null");
119119
Assert.notNull(locations, "Locations must not be null");
120120

121-
return createFlux(connection -> Flux.from(locations)
121+
return createFlux(geoCommands -> Flux.from(locations)
122122
.map(locationList -> locationList.stream()
123123
.map(location -> new GeoLocation<>(rawValue(location.getName()), location.getPoint()))
124124
.collect(Collectors.toList()))
125-
.flatMap(list -> connection.geoAdd(rawKey(key), list)));
125+
.flatMap(list -> geoCommands.geoAdd(rawKey(key), list)));
126126
}
127127

128128
@Override
@@ -132,7 +132,7 @@ public Mono<Distance> distance(K key, V member1, V member2) {
132132
Assert.notNull(member1, "Member 1 must not be null");
133133
Assert.notNull(member2, "Member 2 must not be null");
134134

135-
return createMono(connection -> connection.geoDist(rawKey(key), rawValue(member1), rawValue(member2)));
135+
return createMono(geoCommands -> geoCommands.geoDist(rawKey(key), rawValue(member1), rawValue(member2)));
136136
}
137137

138138
@Override
@@ -143,7 +143,7 @@ public Mono<Distance> distance(K key, V member1, V member2, Metric metric) {
143143
Assert.notNull(member2, "Member 2 must not be null");
144144
Assert.notNull(metric, "Metric must not be null");
145145

146-
return createMono(connection -> connection.geoDist(rawKey(key), rawValue(member1), rawValue(member2), metric));
146+
return createMono(geoCommands -> geoCommands.geoDist(rawKey(key), rawValue(member1), rawValue(member2), metric));
147147
}
148148

149149
@Override
@@ -152,7 +152,7 @@ public Mono<String> hash(K key, V member) {
152152
Assert.notNull(key, "Key must not be null");
153153
Assert.notNull(member, "Member must not be null");
154154

155-
return createMono(connection -> connection.geoHash(rawKey(key), rawValue(member)));
155+
return createMono(geoCommands -> geoCommands.geoHash(rawKey(key), rawValue(member)));
156156
}
157157

158158
@Override
@@ -163,10 +163,10 @@ public final Mono<List<String>> hash(K key, V... members) {
163163
Assert.notEmpty(members, "Members must not be null or empty");
164164
Assert.noNullElements(members, "Members must not contain null elements");
165165

166-
return createMono(connection -> Flux.fromArray(members) //
166+
return createMono(geoCommands -> Flux.fromArray(members) //
167167
.map(this::rawValue) //
168168
.collectList() //
169-
.flatMap(serialized -> connection.geoHash(rawKey(key), serialized)));
169+
.flatMap(serialized -> geoCommands.geoHash(rawKey(key), serialized)));
170170
}
171171

172172
@Override
@@ -175,7 +175,7 @@ public Mono<Point> position(K key, V member) {
175175
Assert.notNull(key, "Key must not be null");
176176
Assert.notNull(member, "Member must not be null");
177177

178-
return createMono(connection -> connection.geoPos(rawKey(key), rawValue(member)));
178+
return createMono(geoCommands -> geoCommands.geoPos(rawKey(key), rawValue(member)));
179179
}
180180

181181
@Override
@@ -186,10 +186,10 @@ public final Mono<List<Point>> position(K key, V... members) {
186186
Assert.notEmpty(members, "Members must not be null or empty");
187187
Assert.noNullElements(members, "Members must not contain null elements");
188188

189-
return createMono(connection -> Flux.fromArray(members) //
189+
return createMono(geoCommands -> Flux.fromArray(members) //
190190
.map(this::rawValue) //
191191
.collectList() //
192-
.flatMap(serialized -> connection.geoPos(rawKey(key), serialized)));
192+
.flatMap(serialized -> geoCommands.geoPos(rawKey(key), serialized)));
193193
}
194194

195195
@Override
@@ -198,7 +198,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, Circle within) {
198198
Assert.notNull(key, "Key must not be null");
199199
Assert.notNull(within, "Circle must not be null");
200200

201-
return createFlux(connection -> connection.geoRadius(rawKey(key), within).map(this::readGeoResult));
201+
return createFlux(geoCommands -> geoCommands.geoRadius(rawKey(key), within).map(this::readGeoResult));
202202
}
203203

204204
@Override
@@ -208,7 +208,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, Circle within, GeoRadiusCom
208208
Assert.notNull(within, "Circle must not be null");
209209
Assert.notNull(args, "GeoRadiusCommandArgs must not be null");
210210

211-
return createFlux(connection -> connection.geoRadius(rawKey(key), within, args) //
211+
return createFlux(geoCommands -> geoCommands.geoRadius(rawKey(key), within, args) //
212212
.map(this::readGeoResult));
213213
}
214214

@@ -218,8 +218,9 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, double radius) {
218218
Assert.notNull(key, "Key must not be null");
219219
Assert.notNull(member, "Member must not be null");
220220

221-
return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), new Distance(radius)) //
222-
.map(this::readGeoResult));
221+
return createFlux(geoCommands ->
222+
geoCommands.geoRadiusByMember(rawKey(key), rawValue(member), new Distance(radius)) //
223+
.map(this::readGeoResult));
223224
}
224225

225226
@Override
@@ -229,7 +230,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance
229230
Assert.notNull(member, "Member must not be null");
230231
Assert.notNull(distance, "Distance must not be null");
231232

232-
return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), distance) //
233+
return createFlux(geoCommands -> geoCommands.geoRadiusByMember(rawKey(key), rawValue(member), distance) //
233234
.map(this::readGeoResult));
234235
}
235236

@@ -241,7 +242,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance
241242
Assert.notNull(distance, "Distance must not be null");
242243
Assert.notNull(args, "GeoRadiusCommandArgs must not be null");
243244

244-
return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), distance, args))
245+
return createFlux(geoCommands -> geoCommands.geoRadiusByMember(rawKey(key), rawValue(member), distance, args))
245246
.map(this::readGeoResult);
246247
}
247248

@@ -308,8 +309,7 @@ private <T> Flux<T> createFlux(Function<ReactiveGeoCommands, Publisher<T>> funct
308309
@SuppressWarnings("unchecked")
309310
private GeoReference<ByteBuffer> getGeoReference(GeoReference<V> reference) {
310311
return reference instanceof GeoReference.GeoMemberReference
311-
? GeoReference
312-
.fromMember(rawValue(((GeoMemberReference<V>) reference).getMember()))
312+
? GeoReference.fromMember(rawValue(((GeoMemberReference<V>) reference).getMember()))
313313
: (GeoReference<ByteBuffer>) reference;
314314
}
315315

@@ -327,7 +327,7 @@ private V readValue(ByteBuffer buffer) {
327327

328328
private GeoResult<GeoLocation<V>> readGeoResult(GeoResult<GeoLocation<ByteBuffer>> source) {
329329

330-
return new GeoResult<>(new GeoLocation(readValue(source.getContent().getName()), source.getContent().getPoint()),
330+
return new GeoResult<>(new GeoLocation<>(readValue(source.getContent().getName()), source.getContent().getPoint()),
331331
source.getDistance());
332332
}
333333
}

src/main/java/org/springframework/data/redis/core/DefaultReactiveHashOperations.java

+16-15
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public Mono<Long> remove(H key, Object... hashKeys) {
6060
Assert.notEmpty(hashKeys, "Hash keys must not be empty");
6161
Assert.noNullElements(hashKeys, "Hash keys must not contain null elements");
6262

63-
return createMono(connection -> Flux.fromArray(hashKeys) //
63+
return createMono(hashCommands -> Flux.fromArray(hashKeys) //
6464
.map(o -> (HK) o).map(this::rawHashKey) //
6565
.collectList() //
66-
.flatMap(hks -> connection.hDel(rawKey(key), hks)));
66+
.flatMap(hks -> hashCommands.hDel(rawKey(key), hks)));
6767
}
6868

6969
@Override
@@ -73,7 +73,7 @@ public Mono<Boolean> hasKey(H key, Object hashKey) {
7373
Assert.notNull(key, "Key must not be null");
7474
Assert.notNull(hashKey, "Hash key must not be null");
7575

76-
return createMono(connection -> connection.hExists(rawKey(key), rawHashKey((HK) hashKey)));
76+
return createMono(hashCommands -> hashCommands.hExists(rawKey(key), rawHashKey((HK) hashKey)));
7777
}
7878

7979
@Override
@@ -83,7 +83,8 @@ public Mono<HV> get(H key, Object hashKey) {
8383
Assert.notNull(key, "Key must not be null");
8484
Assert.notNull(hashKey, "Hash key must not be null");
8585

86-
return createMono(connection -> connection.hGet(rawKey(key), rawHashKey((HK) hashKey)).map(this::readHashValue));
86+
return createMono(hashCommands ->
87+
hashCommands.hGet(rawKey(key), rawHashKey((HK) hashKey)).map(this::readHashValue));
8788
}
8889

8990
@Override
@@ -93,10 +94,10 @@ public Mono<List<HV>> multiGet(H key, Collection<HK> hashKeys) {
9394
Assert.notNull(hashKeys, "Hash keys must not be null");
9495
Assert.notEmpty(hashKeys, "Hash keys must not be empty");
9596

96-
return createMono(connection -> Flux.fromIterable(hashKeys) //
97+
return createMono(hashCommands -> Flux.fromIterable(hashKeys) //
9798
.map(this::rawHashKey) //
9899
.collectList() //
99-
.flatMap(hks -> connection.hMGet(rawKey(key), hks)).map(this::deserializeHashValues));
100+
.flatMap(hks -> hashCommands.hMGet(rawKey(key), hks)).map(this::deserializeHashValues));
100101
}
101102

102103
@Override
@@ -162,7 +163,7 @@ public Flux<HK> keys(H key) {
162163

163164
Assert.notNull(key, "Key must not be null");
164165

165-
return createFlux(connection -> connection.hKeys(rawKey(key)) //
166+
return createFlux(hashCommands -> hashCommands.hKeys(rawKey(key)) //
166167
.map(this::readHashKey));
167168
}
168169

@@ -171,7 +172,7 @@ public Mono<Long> size(H key) {
171172

172173
Assert.notNull(key, "Key must not be null");
173174

174-
return createMono(connection -> connection.hLen(rawKey(key)));
175+
return createMono(hashCommands -> hashCommands.hLen(rawKey(key)));
175176
}
176177

177178
@Override
@@ -180,9 +181,9 @@ public Mono<Boolean> putAll(H key, Map<? extends HK, ? extends HV> map) {
180181
Assert.notNull(key, "Key must not be null");
181182
Assert.notNull(map, "Map must not be null");
182183

183-
return createMono(connection -> Flux.fromIterable(() -> map.entrySet().iterator()) //
184+
return createMono(hashCommands -> Flux.fromIterable(() -> map.entrySet().iterator()) //
184185
.collectMap(entry -> rawHashKey(entry.getKey()), entry -> rawHashValue(entry.getValue())) //
185-
.flatMap(serialized -> connection.hMSet(rawKey(key), serialized)));
186+
.flatMap(serialized -> hashCommands.hMSet(rawKey(key), serialized)));
186187
}
187188

188189
@Override
@@ -192,7 +193,7 @@ public Mono<Boolean> put(H key, HK hashKey, HV value) {
192193
Assert.notNull(hashKey, "Hash key must not be null");
193194
Assert.notNull(value, "Hash value must not be null");
194195

195-
return createMono(connection -> connection.hSet(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
196+
return createMono(hashCommands -> hashCommands.hSet(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
196197
}
197198

198199
@Override
@@ -202,15 +203,15 @@ public Mono<Boolean> putIfAbsent(H key, HK hashKey, HV value) {
202203
Assert.notNull(hashKey, "Hash key must not be null");
203204
Assert.notNull(value, "Hash value must not be null");
204205

205-
return createMono(connection -> connection.hSetNX(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
206+
return createMono(hashCommands -> hashCommands.hSetNX(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
206207
}
207208

208209
@Override
209210
public Flux<HV> values(H key) {
210211

211212
Assert.notNull(key, "Key must not be null");
212213

213-
return createFlux(connection -> connection.hVals(rawKey(key)) //
214+
return createFlux(hashCommands -> hashCommands.hVals(rawKey(key)) //
214215
.map(this::readHashValue));
215216
}
216217

@@ -219,7 +220,7 @@ public Flux<Map.Entry<HK, HV>> entries(H key) {
219220

220221
Assert.notNull(key, "Key must not be null");
221222

222-
return createFlux(connection -> connection.hGetAll(rawKey(key)) //
223+
return createFlux(hashCommands -> hashCommands.hGetAll(rawKey(key)) //
223224
.map(this::deserializeHashEntry));
224225
}
225226

@@ -229,7 +230,7 @@ public Flux<Map.Entry<HK, HV>> scan(H key, ScanOptions options) {
229230
Assert.notNull(key, "Key must not be null");
230231
Assert.notNull(key, "ScanOptions must not be null");
231232

232-
return createFlux(connection -> connection.hScan(rawKey(key), options) //
233+
return createFlux(hashCommands -> hashCommands.hScan(rawKey(key), options) //
233234
.map(this::deserializeHashEntry));
234235
}
235236

src/main/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperations.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public final Mono<Long> add(K key, V... values) {
5353
Assert.notEmpty(values, "Values must not be null or empty");
5454
Assert.noNullElements(values, "Values must not contain null elements");
5555

56-
return createMono(connection -> Flux.fromArray(values) //
56+
return createMono(hyperLogLogCommands -> Flux.fromArray(values) //
5757
.map(this::rawValue) //
5858
.collectList() //
59-
.flatMap(serializedValues -> connection.pfAdd(rawKey(key), serializedValues)));
59+
.flatMap(serializedValues -> hyperLogLogCommands.pfAdd(rawKey(key), serializedValues)));
6060
}
6161

6262
@Override
@@ -66,10 +66,10 @@ public final Mono<Long> size(K... keys) {
6666
Assert.notEmpty(keys, "Keys must not be null or empty");
6767
Assert.noNullElements(keys, "Keys must not contain null elements");
6868

69-
return createMono(connection -> Flux.fromArray(keys) //
69+
return createMono(hyperLogLogCommands -> Flux.fromArray(keys) //
7070
.map(this::rawKey) //
7171
.collectList() //
72-
.flatMap(connection::pfCount));
72+
.flatMap(hyperLogLogCommands::pfCount));
7373
}
7474

7575
@Override
@@ -80,10 +80,10 @@ public final Mono<Boolean> union(K destination, K... sourceKeys) {
8080
Assert.notEmpty(sourceKeys, "Source keys must not be null or empty");
8181
Assert.noNullElements(sourceKeys, "Source keys must not contain null elements");
8282

83-
return createMono(connection -> Flux.fromArray(sourceKeys) //
83+
return createMono(hyperLogLogCommands -> Flux.fromArray(sourceKeys) //
8484
.map(this::rawKey) //
8585
.collectList() //
86-
.flatMap(serialized -> connection.pfMerge(rawKey(destination), serialized)));
86+
.flatMap(serialized -> hyperLogLogCommands.pfMerge(rawKey(destination), serialized)));
8787
}
8888

8989
@Override

0 commit comments

Comments
 (0)