code: public static MultiPolygon extractWalls(Polygon polygon, double height){
          GeometryFactory factory = polygon.getFactory();
          //We process the exterior ring 
          final LineString shell = getClockWise(polygon.getExteriorRing());
  
          ArrayList<Polygon> walls = new ArrayList<Polygon>();
          for (int i = 1; i < shell.getNumPoints(); i++) {
              walls.add(extrudeEdge(shell.getCoordinateN(i - 1), shell.getCoordinateN(i), height, factory));
          }
  
          // We create the walls  for all holes 
          int nbOfHoles = polygon.getNumInteriorRing();
          for (int i = 0; i < nbOfHoles; i++) {
              final LineString hole = getCounterClockWise(polygon.getInteriorRingN(i));
              for (int j = 1; j < hole.getNumPoints(); j++) {
                  walls.add(extrudeEdge(hole.getCoordinateN(j - 1),
                          hole.getCoordinateN(j), height, factory));
              }
          }
          return polygon.getFactory().createMultiPolygon(walls.toArray(new Polygon[0]));
      }
docs: Extract the walls from a polygon
  @param polygon
  @param height
  @return