@@ -68,7 +68,7 @@ public Mono<Long> add(K key, Point point, V member) {
68
68
Assert .notNull (point , "Point must not be null" );
69
69
Assert .notNull (member , "Member must not be null" );
70
70
71
- return createMono (connection -> connection .geoAdd (rawKey (key ), point , rawValue (member )));
71
+ return createMono (geoCommands -> geoCommands .geoAdd (rawKey (key ), point , rawValue (member )));
72
72
}
73
73
74
74
@ Override
@@ -77,7 +77,7 @@ public Mono<Long> add(K key, GeoLocation<V> location) {
77
77
Assert .notNull (key , "Key must not be null" );
78
78
Assert .notNull (location , "GeoLocation must not be null" );
79
79
80
- return createMono (connection -> connection .geoAdd (rawKey (key ),
80
+ return createMono (geoCommands -> geoCommands .geoAdd (rawKey (key ),
81
81
new GeoLocation <>(rawValue (location .getName ()), location .getPoint ())));
82
82
}
83
83
@@ -87,13 +87,13 @@ public Mono<Long> add(K key, Map<V, Point> memberCoordinateMap) {
87
87
Assert .notNull (key , "Key must not be null" );
88
88
Assert .notNull (memberCoordinateMap , "MemberCoordinateMap must not be null" );
89
89
90
- return createMono (connection -> {
90
+ return createMono (geoCommands -> {
91
91
92
92
Mono <List <GeoLocation <ByteBuffer >>> serializedList = Flux
93
93
.fromIterable (() -> memberCoordinateMap .entrySet ().iterator ())
94
94
.map (entry -> new GeoLocation <>(rawValue (entry .getKey ()), entry .getValue ())).collectList ();
95
95
96
- return serializedList .flatMap (list -> connection .geoAdd (rawKey (key ), list ));
96
+ return serializedList .flatMap (list -> geoCommands .geoAdd (rawKey (key ), list ));
97
97
});
98
98
}
99
99
@@ -103,12 +103,12 @@ public Mono<Long> add(K key, Iterable<GeoLocation<V>> geoLocations) {
103
103
Assert .notNull (key , "Key must not be null" );
104
104
Assert .notNull (geoLocations , "GeoLocations must not be null" );
105
105
106
- return createMono (connection -> {
106
+ return createMono (geoCommands -> {
107
107
108
108
Mono <List <GeoLocation <ByteBuffer >>> serializedList = Flux .fromIterable (geoLocations )
109
109
.map (location -> new GeoLocation <>(rawValue (location .getName ()), location .getPoint ())).collectList ();
110
110
111
- return serializedList .flatMap (list -> connection .geoAdd (rawKey (key ), list ));
111
+ return serializedList .flatMap (list -> geoCommands .geoAdd (rawKey (key ), list ));
112
112
});
113
113
}
114
114
@@ -118,11 +118,11 @@ public Flux<Long> add(K key, Publisher<? extends Collection<GeoLocation<V>>> loc
118
118
Assert .notNull (key , "Key must not be null" );
119
119
Assert .notNull (locations , "Locations must not be null" );
120
120
121
- return createFlux (connection -> Flux .from (locations )
121
+ return createFlux (geoCommands -> Flux .from (locations )
122
122
.map (locationList -> locationList .stream ()
123
123
.map (location -> new GeoLocation <>(rawValue (location .getName ()), location .getPoint ()))
124
124
.collect (Collectors .toList ()))
125
- .flatMap (list -> connection .geoAdd (rawKey (key ), list )));
125
+ .flatMap (list -> geoCommands .geoAdd (rawKey (key ), list )));
126
126
}
127
127
128
128
@ Override
@@ -132,7 +132,7 @@ public Mono<Distance> distance(K key, V member1, V member2) {
132
132
Assert .notNull (member1 , "Member 1 must not be null" );
133
133
Assert .notNull (member2 , "Member 2 must not be null" );
134
134
135
- return createMono (connection -> connection .geoDist (rawKey (key ), rawValue (member1 ), rawValue (member2 )));
135
+ return createMono (geoCommands -> geoCommands .geoDist (rawKey (key ), rawValue (member1 ), rawValue (member2 )));
136
136
}
137
137
138
138
@ Override
@@ -143,7 +143,7 @@ public Mono<Distance> distance(K key, V member1, V member2, Metric metric) {
143
143
Assert .notNull (member2 , "Member 2 must not be null" );
144
144
Assert .notNull (metric , "Metric must not be null" );
145
145
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 ));
147
147
}
148
148
149
149
@ Override
@@ -152,7 +152,7 @@ public Mono<String> hash(K key, V member) {
152
152
Assert .notNull (key , "Key must not be null" );
153
153
Assert .notNull (member , "Member must not be null" );
154
154
155
- return createMono (connection -> connection .geoHash (rawKey (key ), rawValue (member )));
155
+ return createMono (geoCommands -> geoCommands .geoHash (rawKey (key ), rawValue (member )));
156
156
}
157
157
158
158
@ Override
@@ -163,10 +163,10 @@ public final Mono<List<String>> hash(K key, V... members) {
163
163
Assert .notEmpty (members , "Members must not be null or empty" );
164
164
Assert .noNullElements (members , "Members must not contain null elements" );
165
165
166
- return createMono (connection -> Flux .fromArray (members ) //
166
+ return createMono (geoCommands -> Flux .fromArray (members ) //
167
167
.map (this ::rawValue ) //
168
168
.collectList () //
169
- .flatMap (serialized -> connection .geoHash (rawKey (key ), serialized )));
169
+ .flatMap (serialized -> geoCommands .geoHash (rawKey (key ), serialized )));
170
170
}
171
171
172
172
@ Override
@@ -175,7 +175,7 @@ public Mono<Point> position(K key, V member) {
175
175
Assert .notNull (key , "Key must not be null" );
176
176
Assert .notNull (member , "Member must not be null" );
177
177
178
- return createMono (connection -> connection .geoPos (rawKey (key ), rawValue (member )));
178
+ return createMono (geoCommands -> geoCommands .geoPos (rawKey (key ), rawValue (member )));
179
179
}
180
180
181
181
@ Override
@@ -186,10 +186,10 @@ public final Mono<List<Point>> position(K key, V... members) {
186
186
Assert .notEmpty (members , "Members must not be null or empty" );
187
187
Assert .noNullElements (members , "Members must not contain null elements" );
188
188
189
- return createMono (connection -> Flux .fromArray (members ) //
189
+ return createMono (geoCommands -> Flux .fromArray (members ) //
190
190
.map (this ::rawValue ) //
191
191
.collectList () //
192
- .flatMap (serialized -> connection .geoPos (rawKey (key ), serialized )));
192
+ .flatMap (serialized -> geoCommands .geoPos (rawKey (key ), serialized )));
193
193
}
194
194
195
195
@ Override
@@ -198,7 +198,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, Circle within) {
198
198
Assert .notNull (key , "Key must not be null" );
199
199
Assert .notNull (within , "Circle must not be null" );
200
200
201
- return createFlux (connection -> connection .geoRadius (rawKey (key ), within ).map (this ::readGeoResult ));
201
+ return createFlux (geoCommands -> geoCommands .geoRadius (rawKey (key ), within ).map (this ::readGeoResult ));
202
202
}
203
203
204
204
@ Override
@@ -208,7 +208,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, Circle within, GeoRadiusCom
208
208
Assert .notNull (within , "Circle must not be null" );
209
209
Assert .notNull (args , "GeoRadiusCommandArgs must not be null" );
210
210
211
- return createFlux (connection -> connection .geoRadius (rawKey (key ), within , args ) //
211
+ return createFlux (geoCommands -> geoCommands .geoRadius (rawKey (key ), within , args ) //
212
212
.map (this ::readGeoResult ));
213
213
}
214
214
@@ -218,8 +218,9 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, double radius) {
218
218
Assert .notNull (key , "Key must not be null" );
219
219
Assert .notNull (member , "Member must not be null" );
220
220
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 ));
223
224
}
224
225
225
226
@ Override
@@ -229,7 +230,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance
229
230
Assert .notNull (member , "Member must not be null" );
230
231
Assert .notNull (distance , "Distance must not be null" );
231
232
232
- return createFlux (connection -> connection .geoRadiusByMember (rawKey (key ), rawValue (member ), distance ) //
233
+ return createFlux (geoCommands -> geoCommands .geoRadiusByMember (rawKey (key ), rawValue (member ), distance ) //
233
234
.map (this ::readGeoResult ));
234
235
}
235
236
@@ -241,7 +242,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance
241
242
Assert .notNull (distance , "Distance must not be null" );
242
243
Assert .notNull (args , "GeoRadiusCommandArgs must not be null" );
243
244
244
- return createFlux (connection -> connection .geoRadiusByMember (rawKey (key ), rawValue (member ), distance , args ))
245
+ return createFlux (geoCommands -> geoCommands .geoRadiusByMember (rawKey (key ), rawValue (member ), distance , args ))
245
246
.map (this ::readGeoResult );
246
247
}
247
248
@@ -308,8 +309,7 @@ private <T> Flux<T> createFlux(Function<ReactiveGeoCommands, Publisher<T>> funct
308
309
@ SuppressWarnings ("unchecked" )
309
310
private GeoReference <ByteBuffer > getGeoReference (GeoReference <V > reference ) {
310
311
return reference instanceof GeoReference .GeoMemberReference
311
- ? GeoReference
312
- .fromMember (rawValue (((GeoMemberReference <V >) reference ).getMember ()))
312
+ ? GeoReference .fromMember (rawValue (((GeoMemberReference <V >) reference ).getMember ()))
313
313
: (GeoReference <ByteBuffer >) reference ;
314
314
}
315
315
@@ -327,7 +327,7 @@ private V readValue(ByteBuffer buffer) {
327
327
328
328
private GeoResult <GeoLocation <V >> readGeoResult (GeoResult <GeoLocation <ByteBuffer >> source ) {
329
329
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 ()),
331
331
source .getDistance ());
332
332
}
333
333
}
0 commit comments