Java Code Examples for com.typesafe.config.ConfigValueType#LIST

The following examples show how to use com.typesafe.config.ConfigValueType#LIST . 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: Config.java    From para with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the configuration class by loading the configuration file.
 * @param conf overrides the default configuration
 */
public static void init(com.typesafe.config.Config conf) {
	try {
		config = ConfigFactory.load().getConfig(PARA);

		if (conf != null) {
			config = conf.withFallback(config);
		}

		configMap = new HashMap<>();
		for (Map.Entry<String, ConfigValue> con : config.entrySet()) {
			if (con.getValue().valueType() != ConfigValueType.LIST) {
				configMap.put(con.getKey(), config.getString(con.getKey()));
			}
		}
	} catch (Exception ex) {
		logger.warn("Para configuration file 'application.(conf|json|properties)' is invalid or missing from classpath.");
		config = com.typesafe.config.ConfigFactory.empty();
	}
}
 
Example 2
Source File: HoconTreeTraversingParser.java    From jackson-dataformat-hocon with Apache License 2.0 6 votes vote down vote up
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 3
Source File: ConfigBeanImpl.java    From mpush with Apache License 2.0 5 votes vote down vote up
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 4
Source File: BaseMessageTemplates.java    From UHC with MIT License 5 votes vote down vote up
@Override
public List<String> getRawStrings(String path) {
    final ConfigValue value = config.getValue(path);

    if (value.valueType() == ConfigValueType.LIST) {
        return config.getStringList(path);
    }

    return Lists.newArrayList(config.getString(path));
}
 
Example 5
Source File: VcapServicesStringParser.java    From ditto with Eclipse Public License 2.0 4 votes vote down vote up
private static ConfigValue convertConfigListToConfigObject(final ConfigValue configValue) {
    if (ConfigValueType.LIST == configValue.valueType()) {
        return getAsConfigObject((ConfigList) configValue);
    }
    return configValue;
}
 
Example 6
Source File: HoconNodeCursor.java    From jackson-dataformat-hocon with Apache License 2.0 4 votes vote down vote up
protected static boolean isArray(ConfigValue value) {
	return value.valueType() == ConfigValueType.LIST;
}