private Map loadGroupsOutputLocation()

in src/main/java/aws/cfn/codegen/json/Codegen.java [70:92]


    private Map<String, File> loadGroupsOutputLocation(String region) throws IOException {
        File output = config.getSettings().getOutput();
        Map<String, GroupSpec> groups = config.getGroups();
        if (!output.exists() && !output.mkdirs()) {
            throw new IOException("Can not create out directory to write " + output);
        }

        File parent = new File(output, region);
        if (!parent.exists() && !parent.mkdirs()) {
            throw new IOException("Can not create directory for region " + region
                + " at " + parent);
        }

        Map<String, File> groupSchemas = new HashMap<>(groups.size());
        for (Map.Entry<String, GroupSpec> each: groups.entrySet()) {
            File out = new File(parent, each.getKey() + "-spec.json");
            if (!out.exists() && !out.createNewFile()) {
                throw new IOException("Can not create output file to write " + out);
            }
            groupSchemas.put(each.getKey(), out);
        }
        return groupSchemas;
    }