@@ -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}
0 commit comments