class CompartmentUtil {

    public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException {

        Bundle.Builder build = Bundle.builder().type(BundleType.COLLECTION);
        for (String compartmentDefintion : compartmentDefinitions) {

            try (InputStreamReader reader = new InputStreamReader(CompartmentUtil.class.getResourceAsStream(compartmentDefintion))) {
                CompartmentDefinition compartmentDefinitionResource = FHIRParser.parser(Format.JSON).parse(reader);

                build.entry(Bundle.Entry.builder().resource(compartmentDefinitionResource).build());

            } catch (FHIRException e) {
                log.warning(String.format(PARSE_EXCEPTION, compartmentDefintion));
            } catch (IOException e1) {
                log.warning(String.format(IO_EXCEPTION, compartmentDefintion));
            }
        }

        Bundle bundle = build.build();
        FHIRGenerator.generator(Format.JSON, true).generate(bundle, out);
        out.println(bundle.toString());

    }

    private  CompartmentUtil();

}