code: public static Geometry addPoint(Geometry geometry, Point point, double tolerance) throws SQLException {
          if(geometry == null || point == null){
              return null;
          }
          if (geometry instanceof MultiPoint) {
              return insertVertexInMultipoint(geometry, point);
          } else if (geometry instanceof LineString) {
              return insertVertexInLineString((LineString) geometry, point, tolerance);
          } else if (geometry instanceof MultiLineString) {
              LineString[] linestrings = new LineString[geometry.getNumGeometries()];
              boolean any = false;
              for (int i = 0; i < geometry.getNumGeometries(); i++) {
                  LineString line = (LineString) geometry.getGeometryN(i);
  
                  LineString inserted = insertVertexInLineString(line, point, tolerance);
                  if (inserted != null) {
                      linestrings[i] = inserted;
                      any = true;
                  } else {
                      linestrings[i] = line;
                  }
              }
              if (any) {
                  return FACTORY.createMultiLineString(linestrings);
              } else {
                  return null;
              }
          } else if (geometry instanceof Polygon) {
              return insertVertexInPolygon((Polygon) geometry, point, tolerance);
          } else if (geometry instanceof MultiPolygon) {
              Polygon[] polygons = new Polygon[geometry.getNumGeometries()];
              boolean any = false;
              for (int i = 0; i < geometry.getNumGeometries(); i++) {
                  Polygon polygon = (Polygon) geometry.getGeometryN(i);
                  Polygon inserted = insertVertexInPolygon(polygon, point, tolerance);
                  if (inserted != null) {
                      any = true;
                      polygons[i] = inserted;
                  } else {
                      polygons[i] = polygon;
                  }
              }
              if (any) {
                  return FACTORY.createMultiPolygon(polygons);
              } else {
                  return null;
              }
          } else if (geometry instanceof Point) {
              return null;
          }
          throw new SQLException("Unknown geometry type" + " : " + geometry.getGeometryType());
      }
docs: Returns a new geometry based on an existing one, with a specific point as
  a new vertex.
  
  @param geometry
  @param point
  @param tolerance
  @return Null if the vertex cannot be inserted
  @throws SQLException If the vertex can be inserted but it makes the
  geometry to be in an invalid shape