@Test public void testGetRootNames() { Set<String> result = PropertiesExt.getRootNames(asList("top1.a", "top2.b", "single"), 1); assertThat(result).contains("top1", "top2"); }
public static Set<String> getRootNames(Collection<String> names, int rootSegments) { Set<String> topNames = new HashSet<>(); names.forEach(n -> { Pair<String, String> parts = split(n, rootSegments); if (parts != null) { topNames.add(parts.getLeft()); } }); return topNames; }
PropertiesExt { public static Set<String> getRootNames(Collection<String> names, int rootSegments) { Set<String> topNames = new HashSet<>(); names.forEach(n -> { Pair<String, String> parts = split(n, rootSegments); if (parts != null) { topNames.add(parts.getLeft()); } }); return topNames; } }
PropertiesExt { public static Set<String> getRootNames(Collection<String> names, int rootSegments) { Set<String> topNames = new HashSet<>(); names.forEach(n -> { Pair<String, String> parts = split(n, rootSegments); if (parts != null) { topNames.add(parts.getLeft()); } }); return topNames; } private  PropertiesExt(); }
PropertiesExt { public static Set<String> getRootNames(Collection<String> names, int rootSegments) { Set<String> topNames = new HashSet<>(); names.forEach(n -> { Pair<String, String> parts = split(n, rootSegments); if (parts != null) { topNames.add(parts.getLeft()); } }); return topNames; } private  PropertiesExt(); static Optional<Map<String, String>> loadFromClassPath(String resourceName); static Map<String, Map<String, String>> groupByRootName(Map<String, String> properties, int rootParts); static Map<String, String> getPropertiesOf(String namePrefix, Map<String, String> properties); static List<String> verifyRootNames(Map<String, String> properties, Set<String> expectedRootNames); static Set<String> getRootNames(Collection<String> names, int rootSegments); static Map<String, Set<String>> splitNames(Collection<String> names, int rootSegments); static Pair<String, String> split(String name, int rootParts); static PropertyNode<Boolean> fullSplit(Collection<String> names); }
PropertiesExt { public static Set<String> getRootNames(Collection<String> names, int rootSegments) { Set<String> topNames = new HashSet<>(); names.forEach(n -> { Pair<String, String> parts = split(n, rootSegments); if (parts != null) { topNames.add(parts.getLeft()); } }); return topNames; } private  PropertiesExt(); static Optional<Map<String, String>> loadFromClassPath(String resourceName); static Map<String, Map<String, String>> groupByRootName(Map<String, String> properties, int rootParts); static Map<String, String> getPropertiesOf(String namePrefix, Map<String, String> properties); static List<String> verifyRootNames(Map<String, String> properties, Set<String> expectedRootNames); static Set<String> getRootNames(Collection<String> names, int rootSegments); static Map<String, Set<String>> splitNames(Collection<String> names, int rootSegments); static Pair<String, String> split(String name, int rootParts); static PropertyNode<Boolean> fullSplit(Collection<String> names);  }