Interface GeometryVisitor<T,E extends Exception>
public interface GeometryVisitor<T,E extends 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:
-
Method Summary