private static <K, V> Map.Entry<K, V> first(final Map<K, V> map) { Preconditions.checkArgument(!map.isEmpty()); return map.entrySet().iterator().next(); }
private static <K, V> Map.Entry<K, V> first(final Map<K, V> map) { Preconditions.checkArgument(!map.isEmpty()); return map.entrySet().iterator().next(); }
public GeoBoundingBox(GeoPoint topLeft, GeoPoint bottomRight) { Preconditions.checkArgument(topLeft.getLat() >= bottomRight.getLat()); Preconditions.checkArgument(topLeft.getLon() <= bottomRight.getLon()); this.topLeft = topLeft; this.bottomRight = bottomRight; }
private Shape convertObjectToShapeIfPossible(Object o) throws IOException { if(o instanceof Shape) return (Shape) o; String geoShapeStringValue = null; if(o instanceof HashMap) { HashMap map = (HashMap) o; Preconditions.checkArgument(map.containsKey("coordinates") && map.containsKey("type")); geoShapeStringValue = (new JSONObject(map)).toString(); } else if (o instanceof String){ geoShapeStringValue = (String) o; } Preconditions.checkNotNull(geoShapeStringValue); XContentParser parser = JsonXContent.jsonXContent.createParser(geoShapeStringValue); parser.nextToken(); return ShapeBuilder.parse(parser).build(); }