Java Code Examples for com.typesafe.config.ConfigValueType#STRING
The following examples show how to use
com.typesafe.config.ConfigValueType#STRING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultScopedConfig.java From ditto with Eclipse Public License 2.0 | 5 votes |
private int tryToGetIntValue(final String path) { try { return config.getInt(path); } catch (final ConfigException.WrongType e) { final ConfigValue configValue = config.getValue(path); if (ConfigValueType.STRING == configValue.valueType()) { return Integer.parseInt(String.valueOf(configValue.unwrapped())); } throw e; } }
Example 2
Source File: DefaultScopedConfig.java From ditto with Eclipse Public License 2.0 | 5 votes |
private long tryToGetLongValue(final String path) { try { return config.getLong(path); } catch (final ConfigException.WrongType e) { final ConfigValue configValue = config.getValue(path); if (ConfigValueType.STRING == configValue.valueType()) { return Long.parseLong(String.valueOf(configValue.unwrapped())); } throw e; } }
Example 3
Source File: DefaultScopedConfig.java From ditto with Eclipse Public License 2.0 | 5 votes |
private double tryToGetDoubleValue(final String path) { try { return config.getDouble(path); } catch (final ConfigException.WrongType e) { final ConfigValue configValue = config.getValue(path); if (ConfigValueType.STRING == configValue.valueType()) { return Double.parseDouble(String.valueOf(configValue.unwrapped())); } throw e; } }
Example 4
Source File: ConfigBeanImpl.java From mpush with Apache License 2.0 | 5 votes |
private static ConfigValueType getValueTypeOrNull(Class<?> parameterClass) { if (parameterClass == Boolean.class || parameterClass == boolean.class) { return ConfigValueType.BOOLEAN; } else if (parameterClass == Integer.class || parameterClass == int.class) { return ConfigValueType.NUMBER; } else if (parameterClass == Double.class || parameterClass == double.class) { return ConfigValueType.NUMBER; } else if (parameterClass == Long.class || parameterClass == long.class) { return ConfigValueType.NUMBER; } else if (parameterClass == String.class) { return ConfigValueType.STRING; } else if (parameterClass == Duration.class) { return null; } else if (parameterClass == ConfigMemorySize.class) { return null; } else if (parameterClass == List.class) { return ConfigValueType.LIST; } else if (parameterClass == Map.class) { return ConfigValueType.OBJECT; } else if (parameterClass == Config.class) { return ConfigValueType.OBJECT; } else if (parameterClass == ConfigObject.class) { return ConfigValueType.OBJECT; } else if (parameterClass == ConfigList.class) { return ConfigValueType.LIST; } else { return null; } }
Example 5
Source File: TemporaryJobs.java From helios with Apache License 2.0 | 5 votes |
private static List<String> getListByKey(final String key, final Config config) { final ConfigList endpointList = config.getList(key); final List<String> stringList = Lists.newArrayList(); for (final ConfigValue v : endpointList) { if (v.valueType() != ConfigValueType.STRING) { throw new RuntimeException("Item in " + key + " list [" + v + "] is not a string"); } stringList.add((String) v.unwrapped()); } return stringList; }
Example 6
Source File: TestMandatoryPathValidation.java From envelope with Apache License 2.0 | 4 votes |
@Test public void testExistsWithWrongType() { Validation v = new MandatoryPathValidation("hello", ConfigValueType.STRING); ValidationResult vr = v.validate(ConfigFactory.parseString("hello = 2")); assertEquals(vr.getValidity(), Validity.INVALID); }
Example 7
Source File: TestAtMostOnePathExistsValidation.java From envelope with Apache License 2.0 | 4 votes |
@Test public void testWrongType() { Validation v = new AtMostOnePathExistsValidation(ConfigValueType.STRING, "hello", "world"); ValidationResult vr = v.validate(ConfigFactory.parseString("hello = 2")); assertEquals(vr.getValidity(), Validity.INVALID); }
Example 8
Source File: TestOptionalPathValidation.java From envelope with Apache License 2.0 | 4 votes |
@Test public void testPathExistsWithWrongType() { Validation v = new OptionalPathValidation("hello", ConfigValueType.STRING); ValidationResult vr = v.validate(ConfigFactory.parseString("hello = 2")); assertEquals(vr.getValidity(), Validity.INVALID); }
Example 9
Source File: TestExactlyOnePathExistsValidation.java From envelope with Apache License 2.0 | 4 votes |
@Test public void testWrongType() { Validation v = new ExactlyOnePathExistsValidation(ConfigValueType.STRING, "hello", "world"); ValidationResult vr = v.validate(ConfigFactory.parseString("hello = 2")); assertEquals(vr.getValidity(), Validity.INVALID); }