@Test public void testCastBooleanTrue() { assertTrue(integerType.cast(Boolean.TRUE) instanceof Long); }
@Override public Object cast(Object obj) { Long value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).longValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0); } else { try { value = Long.valueOf(obj.toString()); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } } return value; }
IntegerType implements Type, Serializable { @Override public Object cast(Object obj) { Long value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).longValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0); } else { try { value = Long.valueOf(obj.toString()); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } } return value; } }
IntegerType implements Type, Serializable { @Override public Object cast(Object obj) { Long value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).longValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0); } else { try { value = Long.valueOf(obj.toString()); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } } return value; } private  IntegerType(); }
IntegerType implements Type, Serializable { @Override public Object cast(Object obj) { Long value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).longValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0); } else { try { value = Long.valueOf(obj.toString()); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } } return value; } private  IntegerType(); @Override String getName(); @Override boolean supportsEq(); @Override boolean supportsOrdering(); @Override JsonNode toJson(JsonNodeFactory factory, Object obj); @Override Object fromJson(JsonNode node); @Override Object cast(Object obj); @SuppressWarnings({"rawtypes", "unchecked"}) @Override int compare(Object v1, Object v2); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
IntegerType implements Type, Serializable { @Override public Object cast(Object obj) { Long value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).longValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0); } else { try { value = Long.valueOf(obj.toString()); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } } return value; } private  IntegerType(); @Override String getName(); @Override boolean supportsEq(); @Override boolean supportsOrdering(); @Override JsonNode toJson(JsonNodeFactory factory, Object obj); @Override Object fromJson(JsonNode node); @Override Object cast(Object obj); @SuppressWarnings({"rawtypes", "unchecked"}) @Override int compare(Object v1, Object v2); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final Type TYPE; static final String NAME; }