code: private void addGeometry(Geometry geom) throws IllegalArgumentException {
          if(!geom.isValid()) {
              throw new IllegalArgumentException("Provided geometry is not valid !");
          }
          if(geom instanceof GeometryCollection) {
              Map<TriangulationPoint, Integer> pts = new HashMap<TriangulationPoint, Integer>(geom.getNumPoints());
              List<Integer> segments = new ArrayList<Integer>(pts.size());
              AtomicInteger pointsCount = new AtomicInteger(0);
              PointHandler pointHandler = new PointHandler(this, pts, pointsCount);
              LineStringHandler lineStringHandler = new LineStringHandler(this, pts, pointsCount, segments);
              for(int geomId = 0; geomId < geom.getNumGeometries(); geomId++) {
                  addSimpleGeometry(geom.getGeometryN(geomId), pointHandler, lineStringHandler);
              }
              int[] index = new int[segments.size()];
              for(int i = 0; i < index.length; i++) {
                  index[i] = segments.get(i);
              }
              // Construct final points array by reversing key,value of hash map
              TriangulationPoint[] ptsArray = new TriangulationPoint[pointsCount.get()];
              for(Map.Entry<TriangulationPoint, Integer> entry : pts.entrySet()) {
                  ptsArray[entry.getValue()] = entry.getKey();
              }
              pts.clear();
              convertedInput = new ConstrainedPointSet(Arrays.asList(ptsArray), index);
          } else {
              addGeometry(geom.getFactory().createGeometryCollection(new Geometry[]{geom}));
          }
      }
docs: Add a geometry to the list of points and edges used by the triangulation.
  @param geom Any geometry
  @throws IllegalArgumentException