Example usage for java.util Map.Entry keySet

List of usage examples for java.util Map.Entry keySet

Introduction

In this page you can find the example usage for java.util Map.Entry keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:eu.itesla_project.modules.validation.OfflineValidationTool.java

private static void writeCsv(Map<String, Map<RuleId, ValidationStatus>> statusPerRulePerCase,
        Map<String, Map<RuleId, Map<HistoDbAttributeId, Object>>> valuesPerRulePerCase, Path outputDir)
        throws IOException {
    Set<RuleId> rulesIds = new TreeSet<>();
    statusPerRulePerCase.values().stream().forEach(e -> rulesIds.addAll(e.keySet()));

    writeComparisonFiles(rulesIds, statusPerRulePerCase, outputDir);
    writeAttributesFiles(rulesIds, valuesPerRulePerCase, outputDir);

    List<String> categories = Arrays.asList(toCategory(OK_S, OK_R), toCategory(OK_S, NOK_R),
            toCategory(NOK_S, OK_R), toCategory(NOK_S, NOK_R), toCategory(OK_S, UNDEF_R),
            toCategory(NOK_S, UNDEF_R), toCategory(UNDEF_S, OK_R), toCategory(UNDEF_S, NOK_R),
            toCategory(UNDEF_S, UNDEF_R));

    Map<RuleId, Map<String, AtomicInteger>> synthesisPerRule = new HashMap<>();
    for (RuleId ruleId : rulesIds) {
        synthesisPerRule.put(ruleId,//w w w .j a  v a  2s.  c o m
                categories.stream().collect(Collectors.toMap(Function.identity(), e -> new AtomicInteger())));
    }
    for (Map.Entry<String, Map<RuleId, ValidationStatus>> e : statusPerRulePerCase.entrySet()) {
        Map<RuleId, ValidationStatus> statusPerRule = e.getValue();
        for (RuleId ruleId : rulesIds) {
            ValidationStatus status = statusPerRule.get(ruleId);
            String category = toCategory(status.isSimulationOkToStr(), status.isRuleOkToStr());
            synthesisPerRule.get(ruleId).get(category).incrementAndGet();
        }
    }

    writeSynthesisFile(synthesisPerRule, categories, outputDir.resolve("synthesis.csv"));
}