@Test public void testCastGoodString() { assertTrue(bigIntegerType.cast(String.valueOf(BigInteger.TEN)) instanceof BigInteger); }
@Override public Object cast(Object obj) { BigInteger value = null; if (obj != null) { if (obj instanceof BigInteger) { value = (BigInteger) obj; } else if (obj instanceof Number) { value = new BigInteger(Long.toString(((Number) obj).longValue())); } else if (obj instanceof Boolean) { value = new BigInteger(((Boolean) obj) ? "1" : "0"); } else if (obj instanceof String) { try { value = new BigInteger((String) obj); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; }
BigIntegerType implements Type, Serializable { @Override public Object cast(Object obj) { BigInteger value = null; if (obj != null) { if (obj instanceof BigInteger) { value = (BigInteger) obj; } else if (obj instanceof Number) { value = new BigInteger(Long.toString(((Number) obj).longValue())); } else if (obj instanceof Boolean) { value = new BigInteger(((Boolean) obj) ? "1" : "0"); } else if (obj instanceof String) { try { value = new BigInteger((String) obj); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; } }
BigIntegerType implements Type, Serializable { @Override public Object cast(Object obj) { BigInteger value = null; if (obj != null) { if (obj instanceof BigInteger) { value = (BigInteger) obj; } else if (obj instanceof Number) { value = new BigInteger(Long.toString(((Number) obj).longValue())); } else if (obj instanceof Boolean) { value = new BigInteger(((Boolean) obj) ? "1" : "0"); } else if (obj instanceof String) { try { value = new BigInteger((String) obj); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; } private  BigIntegerType(); }
BigIntegerType implements Type, Serializable { @Override public Object cast(Object obj) { BigInteger value = null; if (obj != null) { if (obj instanceof BigInteger) { value = (BigInteger) obj; } else if (obj instanceof Number) { value = new BigInteger(Long.toString(((Number) obj).longValue())); } else if (obj instanceof Boolean) { value = new BigInteger(((Boolean) obj) ? "1" : "0"); } else if (obj instanceof String) { try { value = new BigInteger((String) obj); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; } private  BigIntegerType(); @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({"unchecked", "rawtypes"}) @Override int compare(Object v1, Object v2); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
BigIntegerType implements Type, Serializable { @Override public Object cast(Object obj) { BigInteger value = null; if (obj != null) { if (obj instanceof BigInteger) { value = (BigInteger) obj; } else if (obj instanceof Number) { value = new BigInteger(Long.toString(((Number) obj).longValue())); } else if (obj instanceof Boolean) { value = new BigInteger(((Boolean) obj) ? "1" : "0"); } else if (obj instanceof String) { try { value = new BigInteger((String) obj); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; } private  BigIntegerType(); @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({"unchecked", "rawtypes"}) @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; }