ConfigUtils { public static boolean canBeCoerced(Config config, String path, ConfigValueType type) { if (type == ConfigValueType.BOOLEAN) { try { config.getBoolean(path); } catch (ConfigException.WrongType e) { return false; } } else { return false; } return true; }  static Config configFromPath(String path); static Config configFromResource(String resource); static Config applySubstitutions(Config config); static Config applySubstitutions(Config config, String substitutionsString); static Config getApplicationConfig(Config config); static Config mergeLoadedConfiguration(Config config); static Config findReplaceStringValues(Config config, String findRegex, Object replace); static boolean canBeCoerced(Config config, String path, ConfigValueType type); static T getOrElse(Config config, String path, T orElse); static T getOrNull(Config config, String path); static final String JAR_FILE_EXCEPTION_MESSAGE; }
@Test public void testCanBeCoerced() { Config config = ConfigFactory.empty().withValue("hello", ConfigValueFactory.fromAnyRef("true")); assertTrue(ConfigUtils.canBeCoerced(config, "hello", ConfigValueType.BOOLEAN)); }
@Test public void testCanNotBeCoerced() { Config config = ConfigFactory.empty().withValue("hello", ConfigValueFactory.fromAnyRef("maybe?")); assertFalse(ConfigUtils.canBeCoerced(config, "hello", ConfigValueType.BOOLEAN)); }