Example usage for org.apache.commons.configuration AbstractConfiguration getDouble

List of usage examples for org.apache.commons.configuration AbstractConfiguration getDouble

Introduction

In this page you can find the example usage for org.apache.commons.configuration AbstractConfiguration getDouble.

Prototype

public Double getDouble(String key, Double defaultValue) 

Source Link

Usage

From source file:com.netflix.paas.config.base.ConfigurationProxyUtils.java

static Supplier<?> getStaticSupplier(Class<?> type, String key, String defaultValue,
        AbstractConfiguration configuration) {
    if (type.isAssignableFrom(String.class)) {
        return Suppliers.ofInstance(configuration.getString(key, defaultValue));
    } else if (type.isAssignableFrom(Integer.class)) {
        return Suppliers.ofInstance(
                configuration.getInteger(key, defaultValue == null ? 0 : Integer.parseInt(defaultValue)));
    } else if (type.isAssignableFrom(Double.class)) {
        return Suppliers.ofInstance(
                configuration.getDouble(key, defaultValue == null ? 0.0 : Double.parseDouble(defaultValue)));
    } else if (type.isAssignableFrom(Long.class)) {
        return Suppliers.ofInstance(
                configuration.getLong(key, defaultValue == null ? 0L : Long.parseLong(defaultValue)));
    } else if (type.isAssignableFrom(Boolean.class)) {
        return Suppliers.ofInstance(configuration.getBoolean(key,
                defaultValue == null ? false : Boolean.parseBoolean(defaultValue)));
    }/*from   w  ww .  java 2  s . c  om*/
    throw new RuntimeException("Unsupported value type " + type.getCanonicalName());
}