code: public static org.postgis.Geometry convert(Geometry geometry) {
          if (geometry instanceof Point) {
              return convert((Point) geometry);
          } else if (geometry instanceof LinearRing) {
              return convert((LinearRing) geometry);
          } else if (geometry instanceof LineString) {
              return convert((LineString) geometry);
          } else if (geometry instanceof MultiLineString) {
              return convert((MultiLineString) geometry);
          } else if (geometry instanceof Polygon) {
              return convert((Polygon) geometry);
          } else if (geometry instanceof PolyHedralSurface) {
              return convert((PolyHedralSurface) geometry);
          } else if (geometry instanceof MultiPoint) {
              return convert((MultiPoint) geometry);
          } else if (geometry instanceof MultiPolygon) {
              return convert((MultiPolygon) geometry);
          } else if (geometry instanceof GeometryCollection) {
              return convert((GeometryCollection) geometry);
          } else {
              throw new IllegalArgumentException(geometry.getClass().getName());
          }
      }
docs: to postgis