code: public Polygon toPolygon(List<LatLng> latLngs, List<List<LatLng>> holes,
                               boolean hasZ, boolean hasM) {
  
          Polygon polygon = new Polygon(hasZ, hasM);
  
          // Close the ring if needed and determine orientation
          closePolygonRing(latLngs);
          PolygonOrientation ringOrientation = getOrientation(latLngs);
  
          // Add the polygon points
          LineString polygonLineString = new LineString(hasZ, hasM);
          for (LatLng latLng : latLngs) {
              Point point = toPoint(latLng);
              // Add exterior in desired orientation order
              if (exteriorOrientation == null || exteriorOrientation == ringOrientation) {
                  polygonLineString.addPoint(point);
              } else {
                  polygonLineString.getPoints().add(0, point);
              }
          }
          polygon.addRing(polygonLineString);
  
          // Add the holes
          if (holes != null) {
              for (List<LatLng> hole : holes) {
  
                  // Close the hole if needed and determine orientation
                  closePolygonRing(hole);
                  PolygonOrientation ringHoleOrientation = getOrientation(hole);
  
                  LineString holeLineString = new LineString(hasZ, hasM);
                  for (LatLng latLng : hole) {
                      Point point = toPoint(latLng);
                      // Add holes in desired orientation order
                      if (holeOrientation == null || holeOrientation == ringHoleOrientation) {
                          holeLineString.addPoint(point);
                      } else {
                          holeLineString.getPoints().add(0, point);
                      }
                  }
                  polygon.addRing(holeLineString);
              }
          }
  
          return polygon;
      }
docs: Convert a list of {@link LatLng} and list of hole list {@link LatLng} to
  a {@link Polygon}
  
  @param latLngs lat lngs
  @param holes   list of holes
  @param hasZ    has z flag
  @param hasM    has m flag
  @return polygon