public ConfigTuples getAllMatching(String... names) { List<Pattern> patterns = Arrays.asList(names).stream().map(Pattern::compile).collect(Collectors.toList()); List<Section> matching = sections .stream() .filter(s -> patterns.stream().anyMatch(p -> s.get(0).matches(p.pattern()))) .collect(Collectors.toList()); return new ConfigTuples(matching); }
public Optional<String> getStringOfFirst(String name) { return sections.stream().filter(s->s.isNamed(name)).findFirst().map(s->s.get(1)); }
private static TristateFilter.Policy getDefaultFromHead(ConfigTuples.Section section) { if (section.get(0).startsWith("in")) return TristateFilter.Policy.Discard; return TristateFilter.Policy.Keep; }
private static void mapPredicate(ConfigTuples.Section section, ResultFilteringSieve.Builder builder) { int min, max; String incexc = section.get(0); if (incexc.startsWith("in")) { incexc = "include"; } else if (incexc.startsWith("ex")) { incexc = "exclude"; } else { throw new RuntimeException("pattern does not start with 'in' or 'ex' for include or exclude:" + incexc); } if (section.get(1).matches("\\d+-\\d+")) { String[] split = section.get(1).split("-"); min = Integer.valueOf(split[0]); max = Integer.valueOf(split[1]); } else { min = Integer.valueOf(section.get(1)); max = min; } if (min == max) { if (incexc.equals("include")) builder.include(min); else builder.exclude(min); } else { if (incexc.equals("include")) builder.include(min,max); else builder.exclude(min,max); } }