code: public static Polygon extractRoof(Polygon polygon, double height) {
          GeometryFactory factory = polygon.getFactory();
          Polygon roofP =  (Polygon)polygon.copy();
          roofP.apply(new TranslateCoordinateSequenceFilter(height));
          final LinearRing shell = factory.createLinearRing(getCounterClockWise(roofP.getExteriorRing()).getCoordinates());
          final int nbOfHoles = roofP.getNumInteriorRing();
          final LinearRing[] holes = new LinearRing[nbOfHoles];
          for (int i = 0; i < nbOfHoles; i++) {
              holes[i] = factory.createLinearRing(getClockWise(
                      roofP.getInteriorRingN(i)).getCoordinates());
          }
          return factory.createPolygon(shell, holes);
      }
docs: Extract the roof of a polygon
  
  @param polygon
  @param height
  @return