@Override public Sphere convert(Document source) { if (source == null) { return null; } Document center = (Document) source.get("center"); Number radius = (Number) source.get("radius"); Assert.notNull(center, "Center must not be null!"); Assert.notNull(radius, "Radius must not be null!"); Distance distance = new Distance(toPrimitiveDoubleValue(radius)); if (source.containsKey("metric")) { String metricString = (String) source.get("metric"); Assert.notNull(metricString, "Metric must not be null!"); distance = distance.in(Metrics.valueOf(metricString)); } return new Sphere(DocumentToPointConverter.INSTANCE.convert(center), distance); } }
@Override public Sphere convert(Document source) { if (source == null) { return null; } Document center = (Document) source.get("center"); Number radius = (Number) source.get("radius"); Assert.notNull(center, "Center must not be null!"); Assert.notNull(radius, "Radius must not be null!"); Distance distance = new Distance(toPrimitiveDoubleValue(radius)); if (source.containsKey("metric")) { String metricString = (String) source.get("metric"); Assert.notNull(metricString, "Metric must not be null!"); distance = distance.in(Metrics.valueOf(metricString)); } return new Sphere(DocumentToPointConverter.INSTANCE.convert(center), distance); } }
@Override public Circle convert(Document source) { if (source == null) { return null; } Document center = (Document) source.get("center"); Number radius = (Number) source.get("radius"); Assert.notNull(center, "Center must not be null!"); Assert.notNull(radius, "Radius must not be null!"); Distance distance = new Distance(toPrimitiveDoubleValue(radius)); if (source.containsKey("metric")) { String metricString = (String) source.get("metric"); Assert.notNull(metricString, "Metric must not be null!"); distance = distance.in(Metrics.valueOf(metricString)); } return new Circle(DocumentToPointConverter.INSTANCE.convert(center), distance); } }
@Override @SuppressWarnings({ "unchecked" }) public Polygon convert(Document source) { if (source == null) { return null; } List<Document> points = (List<Document>) source.get("points"); List<Point> newPoints = new ArrayList<>(points.size()); for (Document element : points) { Assert.notNull(element, "Point elements of polygon must not be null!"); newPoints.add(DocumentToPointConverter.INSTANCE.convert(element)); } return new Polygon(newPoints); } }
@Override public Circle convert(Document source) { if (source == null) { return null; } Document center = (Document) source.get("center"); Number radius = (Number) source.get("radius"); Assert.notNull(center, "Center must not be null!"); Assert.notNull(radius, "Radius must not be null!"); Distance distance = new Distance(toPrimitiveDoubleValue(radius)); if (source.containsKey("metric")) { String metricString = (String) source.get("metric"); Assert.notNull(metricString, "Metric must not be null!"); distance = distance.in(Metrics.valueOf(metricString)); } return new Circle(DocumentToPointConverter.INSTANCE.convert(center), distance); } }
@Override @SuppressWarnings({ "unchecked" }) public Polygon convert(Document source) { if (source == null) { return null; } List<Document> points = (List<Document>) source.get("points"); List<Point> newPoints = new ArrayList<>(points.size()); for (Document element : points) { Assert.notNull(element, "Point elements of polygon must not be null!"); newPoints.add(DocumentToPointConverter.INSTANCE.convert(element)); } return new Polygon(newPoints); } }