Java Code Examples for com.typesafe.config.ConfigValueType#OBJECT
The following examples show how to use
com.typesafe.config.ConfigValueType#OBJECT .
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: VcapServicesStringParser.java From ditto with Eclipse Public License 2.0 | 6 votes |
private static ConfigObject getAsConfigObject(final ConfigList configList) { final Map<String, ConfigValue> flattenedConfigValues = new HashMap<>(configList.size()); for (int i = 0; i < configList.size(); i++) { final ConfigValue configValue = configList.get(i); final String configPath; if (ConfigValueType.OBJECT == configValue.valueType()) { configPath = getName((ConfigObject) configValue); } else { configPath = String.valueOf(i); } flattenedConfigValues.put(configPath, configValue); } return ConfigValueFactory.fromMap(flattenedConfigValues); }
Example 2
Source File: ComponentConfigurator.java From streams with Apache License 2.0 | 6 votes |
/** * returns a version of a config with only values - no nested objects. * * @param config config * @return result */ private Config valuesOnly(Config config) { for (String key : config.root().keySet()) { LOGGER.debug("key: ", key); try { ConfigValue value = config.getValue(key); LOGGER.debug("child type: ", value.valueType()); if (value.valueType() == ConfigValueType.OBJECT) { config = config.withoutPath(key); } } catch(ConfigException configExceptions) { LOGGER.debug("error processing"); config = config.withoutPath("\""+key+"\""); } } return config; }
Example 3
Source File: HoconTreeTraversingParser.java From jackson-dataformat-hocon with Apache License 2.0 | 6 votes |
public HoconTreeTraversingParser(ConfigObject n, ObjectCodec codec) { super(0); _rootObject = n; _objectCodec = codec; if (n.valueType() == ConfigValueType.LIST) { _nextToken = JsonToken.START_ARRAY; _nodeCursor = new HoconNodeCursor.Array(n, null); } else if (n.valueType() == ConfigValueType.OBJECT) { if (HoconNodeCursor.isNumericallyIndexed(n)) { _nextToken = JsonToken.START_ARRAY; _nodeCursor = new HoconNodeCursor.NumericallyIndexedObjectBackedArray(n, null); } else { _nextToken = JsonToken.START_OBJECT; _nodeCursor = new HoconNodeCursor.Object(n, null); } } else { // value node _nodeCursor = new HoconNodeCursor.RootValue(n, null); } }
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: ConfigUtils.java From envelope with Apache License 2.0 | 5 votes |
public static <T> T getOrElse(Config config, String path, T orElse) { if (config.hasPath(path)) { if (config.getValue(path).valueType() == ConfigValueType.OBJECT) { return (T) config.getConfig(path); } else { return (T) config.getAnyRef(path); } } else { return orElse; } }
Example 6
Source File: HoconNodeCursor.java From jackson-dataformat-hocon with Apache License 2.0 | 4 votes |
protected static boolean isObject(ConfigValue value) { return value.valueType() == ConfigValueType.OBJECT; }