protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName) { Object value; if (typeName.equals(String.class.getName())) { value = (propSimple == null) ? null : propSimple.getStringValue(); } else if (typeName.equals(Boolean.class.getName()) || typeName.equals(boolean.class.getName())) { value = (propSimple == null) ? null : propSimple.getBooleanValue(); } else if (typeName.equals(Integer.class.getName()) || typeName.equals(int.class.getName())) { value = (propSimple == null) ? null : propSimple.getIntegerValue(); } else if (typeName.equals(Long.class.getName()) || typeName.equals(long.class.getName())) { value = (propSimple == null) ? null : propSimple.getLongValue(); } else if (typeName.equals(Float.class.getName()) || typeName.equals(float.class.getName())) { value = (propSimple == null) ? null : propSimple.getFloatValue(); } else if (typeName.equals(Double.class.getName()) || typeName.equals(double.class.getName())) { value = (propSimple == null) ? null : propSimple.getDoubleValue(); } else { throw new IllegalStateException("Operation parameter maps to MBean parameter with an unsupported type (" + typeName + ")."); } // TODO GH: Handle rest of types. (I think i have a mapper for this in mc4j return value; } }
} else if (expectedReturn.getName().equals(Float.class.getName()) || expectedReturn.getName().equals(Float.TYPE.getName())) { return simple.getFloatValue(); } else if (expectedReturn.getName().equals(Double.class.getName()) || expectedReturn.getName().equals(Double.TYPE.getName())) {
/** * Return the object representation of the passed PropertySimple for the passed type * @param prop Property to evaluate * @param type Type to convert into * @return Converted object -- if no valid type is found, a String-value is returned. */ private Object getObjectForProperty(PropertySimple prop, PropertySimpleType type) { switch (type) { case STRING: return prop.getStringValue(); case INTEGER: return prop.getIntegerValue(); case BOOLEAN: return prop.getBooleanValue(); case LONG: return prop.getLongValue(); case FLOAT: return prop.getFloatValue(); case DOUBLE: return prop.getDoubleValue(); default: return prop.getStringValue(); } }
attribute.setValue(property.getFloatValue()); break;