Example usage for org.apache.commons.configuration Configuration getByte

List of usage examples for org.apache.commons.configuration Configuration getByte

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getByte.

Prototype

Byte getByte(String key, Byte defaultValue);

Source Link

Document

Get a Byte associated with the given configuration key.

Usage

From source file:com.germinus.easyconf.ComponentProperties.java

protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties,
        Object defaultValue) {/*ww  w  .j  a  va2s .  c  o  m*/
    if (theClass.equals(Float.class)) {
        return properties.getFloat(key, (Float) defaultValue);

    } else if (theClass.equals(Integer.class)) {
        return properties.getInteger(key, (Integer) defaultValue);

    } else if (theClass.equals(String.class)) {
        return properties.getString(key, (String) defaultValue);

    } else if (theClass.equals(Double.class)) {
        return properties.getDouble(key, (Double) defaultValue);

    } else if (theClass.equals(Long.class)) {
        return properties.getLong(key, (Long) defaultValue);

    } else if (theClass.equals(Boolean.class)) {
        return properties.getBoolean(key, (Boolean) defaultValue);

    } else if (theClass.equals(List.class)) {
        return properties.getList(key, (List) defaultValue);

    } else if (theClass.equals(BigInteger.class)) {
        return properties.getBigInteger(key, (BigInteger) defaultValue);

    } else if (theClass.equals(BigDecimal.class)) {
        return properties.getBigDecimal(key, (BigDecimal) defaultValue);

    } else if (theClass.equals(Byte.class)) {
        return properties.getByte(key, (Byte) defaultValue);

    } else if (theClass.equals(Short.class)) {
        return properties.getShort(key, (Short) defaultValue);
    }
    throw new IllegalArgumentException("Class " + theClass + " is not" + "supported for properties");
}