code: public static GeometryCollection createCDT(Geometry geometry, int flag) throws SQLException {
          if (geometry != null) {
              DelaunayData delaunayData = new DelaunayData();
              delaunayData.put(geometry, DelaunayData.MODE.CONSTRAINED);
              delaunayData.triangulate();
              if (flag == 0) {
                  return delaunayData.getTriangles();
              } else if (flag == 1) {
                  return delaunayData.getTrianglesSides();
              } else {
                  throw new SQLException("Only flag 0 or 1 is supported.");
              }
          }
          return null;
      }
docs: Build a constrained delaunay triangulation based on a geometry
  (point, line, polygon)
  
  @param geometry
  @param flag
  @return a set of polygons (triangles)
  @throws SQLException