Package org.elasticsearch.geometry
Interface GeometryVisitor<T,E extends java.lang.Exception>
-
public interface GeometryVisitor<T,E extends java.lang.Exception>
Support class for creating Geometry Visitors.This is an implementation of the Visitor pattern. The basic idea is to simplify adding new operations on Geometries, without constantly modifying and adding new functionality to the Geometry hierarchy and keeping it as lightweight as possible.
It is a more object-oriented alternative to structures like this:
if (obj instanceof This) { doThis((This) obj); } elseif (obj instanceof That) { doThat((That) obj); ... } else { throw new IllegalArgumentException("Unknown object " + obj); }
The Visitor Pattern replaces this structure with Interface inheritance making it easier to identify all places that are using this structure, and making a shape a compile-time failure instead of runtime.
See
WellKnownText.toWKT(Geometry, StringBuilder)
for an example of how this interface is used.- See Also:
- Visitor Pattern
-
-
Method Summary
Modifier and Type Method Description T
visit(Circle circle)
T
visit(GeometryCollection<?> collection)
T
visit(Line line)
T
visit(LinearRing ring)
T
visit(MultiLine multiLine)
T
visit(MultiPoint multiPoint)
T
visit(MultiPolygon multiPolygon)
T
visit(Point point)
T
visit(Polygon polygon)
T
visit(Rectangle rectangle)
-
-
-
Method Detail
-
visit
T visit(Circle circle) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(GeometryCollection<?> collection) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(Line line) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(LinearRing ring) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(MultiLine multiLine) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(MultiPoint multiPoint) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(MultiPolygon multiPolygon) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(Point point) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
visit
T visit(Polygon polygon) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
-