List of utility methods to do Type Coerce
Integer | coerceTagValueInt(String tag, Object val) coerce Tag Value Int if (val == null) return null; if (val instanceof Integer) { return (Integer) val; if (!(val instanceof Number)) { throw new RuntimeException("Value for tag " + tag + " is not Number: " + val.getClass()); final long longVal = ((Number) val).longValue(); if (longVal < Integer.MIN_VALUE || longVal > Integer.MAX_VALUE) { throw new RuntimeException("Value for tag " + tag + " is not in Integer range: " + longVal); return (int) longVal; |
double | coerceToDouble(Object o) coerce To Double if (o instanceof Number) { return ((Number) o).doubleValue(); } else { try { return Double.parseDouble(o.toString()); } catch (NumberFormatException e) { return Double.NaN; |
String | coerceToEntrySize(String s) Coerces a String into a Doom-standard 8-character format. return coerceToEntry(s).trim();
|
String | coerceToString(Object object) coerce To String return coerceToString(object, null);
|
T | coerceToType(Object objectIn, Class coerce To Type return coerceToType(objectIn, clazz, null);
|
Object | coerceTypes(Class clazz, Object value) Coerce numeric types when mapping properties from nodes to entities. if (clazz.isPrimitive() && value == null) { return defaultForPrimitive(clazz, value); if (value != null) { String className = clazz.getName(); if ("int".equals(className) || Integer.class.equals(clazz)) { if (value.getClass().equals(Long.class)) { Long longValue = (Long) value; ... |
Object | coerceTypes(Class clazz, Object value) Coerce numeric types when mapping properties from nodes to entities. if (clazz.isPrimitive() && value == null) { return defaultForPrimitive(clazz, value); if (value != null) { String className = clazz.getName(); if ("int".equals(className) || Integer.class.equals(clazz)) { if (value.getClass().equals(Long.class)) { Long longValue = (Long) value; ... |