@Test @Ignore public void testGetSubsectionsFromParent_01() { properties.clear(); properties.setProperty("system.db.user", "test_user"); properties.setProperty("system.db.password", "password"); properties.setProperty("system.host.port", "8080"); properties.setProperty("system.host.ip", "180.35.35.32"); List<String> expected = Arrays.asList("db", "host");; List<String> actual = Arrays.asList(configObject.getSubsections("system")); assertNotNull(actual); assertThat(actual, containsInAnyOrder(expected.toArray(new String[expected.size()]))); }
public String[] getSubsections() { LinkedHashSet<String> sections = new LinkedHashSet<>(); for (String prop : config.stringPropertyNames()) { int i = prop.indexOf('.'); if (i != 0) { sections.add(prop.substring(0, i)); } } if (sections.size() == 0) { return null; } return sections.toArray(new String[sections.size()]); }
ConfigObject { public String[] getSubsections() { LinkedHashSet<String> sections = new LinkedHashSet<>(); for (String prop : config.stringPropertyNames()) { int i = prop.indexOf('.'); if (i != 0) { sections.add(prop.substring(0, i)); } } if (sections.size() == 0) { return null; } return sections.toArray(new String[sections.size()]); } }
ConfigObject { public String[] getSubsections() { LinkedHashSet<String> sections = new LinkedHashSet<>(); for (String prop : config.stringPropertyNames()) { int i = prop.indexOf('.'); if (i != 0) { sections.add(prop.substring(0, i)); } } if (sections.size() == 0) { return null; } return sections.toArray(new String[sections.size()]); } ConfigObject(File propertiesFile);  ConfigObject(InputStream is);  ConfigObject(String path);  ConfigObject(Properties props); private  ConfigObject(String section, Properties props); private  String(String property); }
ConfigObject { public String[] getSubsections() { LinkedHashSet<String> sections = new LinkedHashSet<>(); for (String prop : config.stringPropertyNames()) { int i = prop.indexOf('.'); if (i != 0) { sections.add(prop.substring(0, i)); } } if (sections.size() == 0) { return null; } return sections.toArray(new String[sections.size()]); } ConfigObject(File propertiesFile);  ConfigObject(InputStream is);  ConfigObject(String path);  ConfigObject(Properties props); private  ConfigObject(String section, Properties props); private  String(String property); static ConfigObject forResource(String resource); static boolean isTrueValue(String value); static boolean isTrueValue(String value, boolean dfault); static boolean isEnabled(String propName); static boolean isEnabled(Properties config, String propName); static boolean isEnabled(String propName, boolean dfault); static boolean isEnabled(Properties config, String propName, boolean dfault); boolean hasProperty(String property); List<String> getPropertyNames(); Properties getProperties(); String get(String property); int getInt(String property); String get(String property, String dfault); String get(String property, boolean emptyIsNull); String get(String property, String dfault, boolean emptyIsDefault); boolean isTrue(String property); boolean isTrue(String property, boolean dfault); String required(String property); @SuppressWarnings("unchecked") T required(String property, Class<T> castTo); File getFile(String property); File getDirectory(String property); Path getPath(String property); String[] getArray(String property); String[] getArray(String property, char separator); String[] requiredArray(String property); String[] requiredArray(String property, char separator); String getParentSection(); ConfigObject getSection(String prefix); boolean hasSection(String prefix); String[] getSubsections(); String[] getSubsections(String parentSection); void set(String property, String value); }
ConfigObject { public String[] getSubsections() { LinkedHashSet<String> sections = new LinkedHashSet<>(); for (String prop : config.stringPropertyNames()) { int i = prop.indexOf('.'); if (i != 0) { sections.add(prop.substring(0, i)); } } if (sections.size() == 0) { return null; } return sections.toArray(new String[sections.size()]); } ConfigObject(File propertiesFile);  ConfigObject(InputStream is);  ConfigObject(String path);  ConfigObject(Properties props); private  ConfigObject(String section, Properties props); private  String(String property); static ConfigObject forResource(String resource); static boolean isTrueValue(String value); static boolean isTrueValue(String value, boolean dfault); static boolean isEnabled(String propName); static boolean isEnabled(Properties config, String propName); static boolean isEnabled(String propName, boolean dfault); static boolean isEnabled(Properties config, String propName, boolean dfault); boolean hasProperty(String property); List<String> getPropertyNames(); Properties getProperties(); String get(String property); int getInt(String property); String get(String property, String dfault); String get(String property, boolean emptyIsNull); String get(String property, String dfault, boolean emptyIsDefault); boolean isTrue(String property); boolean isTrue(String property, boolean dfault); String required(String property); @SuppressWarnings("unchecked") T required(String property, Class<T> castTo); File getFile(String property); File getDirectory(String property); Path getPath(String property); String[] getArray(String property); String[] getArray(String property, char separator); String[] requiredArray(String property); String[] requiredArray(String property, char separator); String getParentSection(); ConfigObject getSection(String prefix); boolean hasSection(String prefix); String[] getSubsections(); String[] getSubsections(String parentSection); void set(String property, String value);  }