org.apache.commons.configuration.PropertyConverter Java Examples

The following examples show how to use org.apache.commons.configuration.PropertyConverter. 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: TypedOption.java    From hugegraph-common with Apache License 2.0 6 votes vote down vote up
protected Object parse(Object value, Class<?> dataType) {
    if (dataType.equals(String.class)) {
        return value;
    } else if (List.class.isAssignableFrom(dataType)) {
        E.checkState(this.forList(),
                     "List option can't be registered with class %s",
                     this.getClass().getSimpleName());
    }

    // Use PropertyConverter method `toXXX` convert value
    String methodTo = "to" + dataType.getSimpleName();
    try {
        Method method = PropertyConverter.class.getMethod(
                        methodTo, Object.class);
        return method.invoke(null, value);
    } catch (ReflectiveOperationException e) {
        LOG.error("Invalid type of value '{}' for option '{}'",
                  value, this.name, e);
        throw new ConfigException(
                  "Invalid type of value '%s' for option '%s', " +
                  "expect '%s' type",
                  value, this.name, dataType.getSimpleName());
    }
}
 
Example #2
Source File: PropertyUtil.java    From qaf with MIT License 5 votes vote down vote up
@Override
public void setProperty(String key, Object value) {
	// allow List Delimiter for string value
	if (null != value && value instanceof String) {
		if (value.toString().indexOf(getListDelimiter()) > 0) {
			value = PropertyConverter.split(value.toString(), getListDelimiter());
		}
	}
	super.setProperty(key, value);
}
 
Example #3
Source File: PatternSpikeGenerator.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public PatternSpikeGenerator(Map<String, Object> templateConfig) {
    this(PropertyConverter.toDouble(templateConfig.getOrDefault("baseline", 0)),
            DistributionType.valueOf(templateConfig.getOrDefault("arrivalType", "lognormal").toString().toUpperCase()),
            PropertyConverter.toDouble(templateConfig.getOrDefault("arrivalMean", 2)),
            PropertyConverter.toDouble(templateConfig.getOrDefault("arrivalSigma", 1)),
            DistributionType.valueOf(templateConfig.getOrDefault("magnitudeType", "lognormal").toString().toUpperCase()),
            PropertyConverter.toDouble(templateConfig.getOrDefault("magnitudeMean", 2)),
            PropertyConverter.toDouble(templateConfig.getOrDefault("magnitudeSigma", 1)),
            PropertyConverter.toDouble(templateConfig.getOrDefault("smoothing", 0)),
            PropertyConverter.toInteger(templateConfig.getOrDefault("seed", 0)));
}
 
Example #4
Source File: PatternSeasonalGenerator.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public PatternSeasonalGenerator(Map<String, Object> templateConfig) {
    this(PropertyConverter.toDouble(templateConfig.getOrDefault("mean", 0)),
            PropertyConverter.toDouble(templateConfig.getOrDefault("sigma", 0)),
            PropertyConverter.toDouble(templateConfig.getOrDefault("trend", 0)),
            PropertyConverter.toDouble(templateConfig.getOrDefault("wavelength", 0)),
            PropertyConverter. toDouble(templateConfig.getOrDefault("amplitude", 0)),
            PropertyConverter. toDouble(templateConfig.getOrDefault("offset", 0)),
            PropertyConverter. toInteger(templateConfig.getOrDefault("seed", 0)),
            toDoubleArray(templateConfig.get("scalingFactors"), 1));
}
 
Example #5
Source File: PatternStringGenerator.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public PatternStringGenerator(Map<String, Object> templateConfig) {
    this(((List<String>) templateConfig.get("values")).toArray(new String[0]),
            PropertyConverter.toLong(templateConfig.getOrDefault("repetitions", 1)));
}
 
Example #6
Source File: PatternSequenceGenerator.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public PatternSequenceGenerator(Map<String, Object> templateConfig) {
    this(PropertyConverter.toLong(templateConfig.getOrDefault("start", 0)),
            PropertyConverter.toLong(templateConfig.getOrDefault("stepsize", 1)),
            PropertyConverter.toLong(templateConfig.getOrDefault("repetitions", 1)));
}