PropertiesExt { public static List<String> verifyRootNames(Map<String, String> properties, Set<String> expectedRootNames) { if (CollectionsExt.isNullOrEmpty(properties)) { return Collections.emptyList(); } List<String> notMatching = new ArrayList<>(); for (String key : properties.keySet()) { String name = key.trim(); int idx = name.indexOf('.'); String rootPart = (idx == -1 || idx == name.length() - 1) ? name : name.substring(0, idx); if (!expectedRootNames.contains(rootPart)) { notMatching.add(name); } } return notMatching; } 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);  }
@Test public void testVerifyRootName() throws Exception { Map<String, String> properties = asMap( "my", "valueA", "your.x", "valueX", "their.y", "valueY" ); List<String> notMatching = PropertiesExt.verifyRootNames(properties, asSet("my", "your")); assertThat(notMatching).containsExactly("their.y"); }