@@ -95,15 +95,9 @@ public Object convertResult(final Class<?> type) {
9595 private Object convert (Class <?> type ) {
9696 if (type .isArray ()) {
9797 return convertArray ();
98- } else if (List .class .equals (type )) {
98+ } else if (List .class .equals (type ) || Iterable . class . equals ( type ) || Collection . class . equals ( type ) ) {
9999 return convertList ();
100- } else if (Iterable .class .equals (type )) {
101- return convertList ();
102- } else if (Collection .class .equals (type )) {
103- return convertList ();
104- } else if (Page .class .equals (type )) {
105- return convertPage ();
106- } else if (Slice .class .equals (type )) {
100+ } else if (Page .class .equals (type ) || Slice .class .equals (type )) {
107101 return convertPage ();
108102 } else if (Set .class .equals (type )) {
109103 return convertSet ();
@@ -139,29 +133,7 @@ private Set<?> buildSet(final ArangoCursor<?> cursor) {
139133 * @return GeoResult object
140134 */
141135 private GeoResult <?> buildGeoResult (final ArangoCursor <?> cursor ) {
142- GeoResult <?> geoResult = null ;
143- // FIXME
144- while (cursor .hasNext () && geoResult == null ) {
145- final Object object = cursor .next ();
146- if (!(object instanceof TxJsonNode )) {
147- // FIXME
148- continue ;
149- }
150-
151- final TxJsonNode data = (TxJsonNode ) object ;
152- final JsonNode slice = data .value ();
153- final JsonNode distSlice = slice .get ("_distance" );
154- final Double distanceInMeters = distSlice .isDouble () ? distSlice .doubleValue () : null ;
155- if (distanceInMeters == null ) {
156- // FIXME
157- continue ;
158- }
159-
160- final Object entity = operations .getConverter ().read (domainClass , data );
161- final Distance distance = new Distance (distanceInMeters / 1000 , Metrics .KILOMETERS );
162- geoResult = new GeoResult <>(entity , distance );
163- }
164- return geoResult ;
136+ return buildGeoResult (cursor .next ());
165137 }
166138
167139 /**
@@ -171,20 +143,10 @@ private GeoResult<?> buildGeoResult(final ArangoCursor<?> cursor) {
171143 * @return GeoResult object
172144 */
173145 private GeoResult <?> buildGeoResult (final Object object ) {
174- if (object == null || !(object instanceof TxJsonNode )) {
175- // FIXME
176- return null ;
177- }
178-
179146 final TxJsonNode data = (TxJsonNode ) object ;
180147 final JsonNode slice = data .value ();
181148 final JsonNode distSlice = slice .get ("_distance" );
182149 final Double distanceInMeters = distSlice .isDouble () ? distSlice .doubleValue () : null ;
183- if (distanceInMeters == null ) {
184- // FIXME
185- return null ;
186- }
187-
188150 final Object entity = operations .getConverter ().read (domainClass , data );
189151 final Distance distance = new Distance (distanceInMeters / 1000 , Metrics .KILOMETERS );
190152 return new GeoResult <>(entity , distance );
@@ -199,12 +161,7 @@ private GeoResult<?> buildGeoResult(final Object object) {
199161 @ SuppressWarnings ({"rawtypes" , "unchecked" })
200162 private GeoResults <?> buildGeoResults (final ArangoCursor <?> cursor ) {
201163 final List <GeoResult <?>> list = new LinkedList <>();
202- cursor .forEachRemaining (o -> {
203- final GeoResult <?> geoResult = buildGeoResult (o );
204- if (geoResult != null ) {
205- list .add (geoResult );
206- }
207- });
164+ cursor .forEachRemaining (o -> list .add (buildGeoResult (o )));
208165 return new GeoResults (list );
209166 }
210167
0 commit comments