use of org.jgroups.conf.AttributeType in project JGroups by belaban.
the class ResourceDMBean method prettyPrint.
@SuppressWarnings("MalformedFormatString")
public static String prettyPrint(Object val, AccessibleObject a) {
if (val == null)
return "null";
Class<?> cl = val.getClass();
AttributeType type = getType(a);
if (type != null) {
switch(type) {
case BYTES:
return Util.printBytes(((Number) val).doubleValue());
case TIME:
TimeUnit unit = getTimeUnit(a);
return Util.printTime(((Number) val).doubleValue(), unit);
case SCALAR:
if (isNumeric(cl))
return String.format("%,d", val);
break;
}
}
if (isNumeric(cl))
return String.format("%d", val);
if (isFractional(cl))
return String.format("%,.2f", val);
return val.toString();
}
Aggregations