class RestUtils {

    public static String groupedModelToString(Model model, RDFFormat format, SesameTransformer transformer) {
        long start = System.currentTimeMillis();
        try {
            StringWriter sw = new StringWriter();
            RDFHandler rdfWriter = new BufferedGroupingRDFHandler(Rio.createWriter(format, sw));
            Rio.write(new StatementIterable(model, transformer), rdfWriter);
            return sw.toString();
        } finally {
            LOG.trace("groupedModelToString took {}ms", System.currentTimeMillis() - start);
        }
    }

}