@Override public boolean isCoercibleTo(PDataType targetType) { return equalsAny(targetType, this, PFloat.INSTANCE) || PLong.INSTANCE.isCoercibleTo(targetType); }
@Override public Integer toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l == 0) { return null; } if (equalsAny(actualType, PLong.INSTANCE, PUnsignedLong.INSTANCE, PInteger.INSTANCE, PUnsignedInt.INSTANCE, PSmallint.INSTANCE, PUnsignedSmallint.INSTANCE, PTinyint.INSTANCE, PUnsignedTinyint.INSTANCE, PFloat.INSTANCE, PUnsignedFloat.INSTANCE, PDouble.INSTANCE, PUnsignedDouble.INSTANCE)) { return actualType.getCodec().decodeInt(b, o, sortOrder); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return bd.intValueExact(); } throwConstraintViolationException(actualType, this); return null; }
@Override public boolean isCoercibleTo(PDataType targetType, Object value) { if (value != null) { int i; if (equalsAny(targetType, PUnsignedDouble.INSTANCE, PUnsignedFloat.INSTANCE, PUnsignedLong.INSTANCE, PUnsignedInt.INSTANCE)) { i = (Integer) value; return i >= 0; } else if (targetType.equals(PUnsignedSmallint.INSTANCE)) { i = (Integer) value; return (i >= 0 && i <= Short.MAX_VALUE); } else if (targetType.equals(PSmallint.INSTANCE)) { i = (Integer) value; return (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE); } else if (targetType.equals(PTinyint.INSTANCE)) { i = (Integer) value; return (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE); } else if (targetType.equals(PUnsignedTinyint.INSTANCE)) { i = (Integer) value; return (i >= 0 && i <= Byte.MAX_VALUE); } } return super.isCoercibleTo(targetType, value); }
@Override public boolean isCoercibleTo(PDataType targetType) { return equalsAny(targetType, this, PFloat.INSTANCE) || PLong.INSTANCE.isCoercibleTo(targetType); }
@Override public boolean isCoercibleTo(PDataType targetType) { return equalsAny(targetType, this, PFloat.INSTANCE) || PLong.INSTANCE.isCoercibleTo(targetType); }
@Override public Integer toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l == 0) { return null; } if (equalsAny(actualType, PLong.INSTANCE, PUnsignedLong.INSTANCE, PInteger.INSTANCE, PUnsignedInt.INSTANCE, PSmallint.INSTANCE, PUnsignedSmallint.INSTANCE, PTinyint.INSTANCE, PUnsignedTinyint.INSTANCE, PFloat.INSTANCE, PUnsignedFloat.INSTANCE, PDouble.INSTANCE, PUnsignedDouble.INSTANCE)) { return actualType.getCodec().decodeInt(b, o, sortOrder); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return bd.intValueExact(); } throwConstraintViolationException(actualType, this); return null; }
@Override public Integer toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { if (l == 0) { return null; } if (equalsAny(actualType, PLong.INSTANCE, PUnsignedLong.INSTANCE, PInteger.INSTANCE, PUnsignedInt.INSTANCE, PSmallint.INSTANCE, PUnsignedSmallint.INSTANCE, PTinyint.INSTANCE, PUnsignedTinyint.INSTANCE, PFloat.INSTANCE, PUnsignedFloat.INSTANCE, PDouble.INSTANCE, PUnsignedDouble.INSTANCE)) { return actualType.getCodec().decodeInt(b, o, sortOrder); } else if (actualType == PDecimal.INSTANCE) { BigDecimal bd = (BigDecimal) actualType.toObject(b, o, l, actualType, sortOrder); return bd.intValueExact(); } throwConstraintViolationException(actualType, this); return null; }
@Override public boolean isCoercibleTo(PDataType targetType, Object value) { if (value != null) { int i; if (equalsAny(targetType, PUnsignedDouble.INSTANCE, PUnsignedFloat.INSTANCE, PUnsignedLong.INSTANCE, PUnsignedInt.INSTANCE)) { i = (Integer) value; return i >= 0; } else if (targetType.equals(PUnsignedSmallint.INSTANCE)) { i = (Integer) value; return (i >= 0 && i <= Short.MAX_VALUE); } else if (targetType.equals(PSmallint.INSTANCE)) { i = (Integer) value; return (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE); } else if (targetType.equals(PTinyint.INSTANCE)) { i = (Integer) value; return (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE); } else if (targetType.equals(PUnsignedTinyint.INSTANCE)) { i = (Integer) value; return (i >= 0 && i <= Byte.MAX_VALUE); } } return super.isCoercibleTo(targetType, value); }
@Override public boolean isCoercibleTo(PDataType targetType, Object value) { if (value != null) { int i; if (equalsAny(targetType, PUnsignedDouble.INSTANCE, PUnsignedFloat.INSTANCE, PUnsignedLong.INSTANCE, PUnsignedInt.INSTANCE)) { i = (Integer) value; return i >= 0; } else if (targetType.equals(PUnsignedSmallint.INSTANCE)) { i = (Integer) value; return (i >= 0 && i <= Short.MAX_VALUE); } else if (targetType.equals(PSmallint.INSTANCE)) { i = (Integer) value; return (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE); } else if (targetType.equals(PTinyint.INSTANCE)) { i = (Integer) value; return (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE); } else if (targetType.equals(PUnsignedTinyint.INSTANCE)) { i = (Integer) value; return (i >= 0 && i <= Byte.MAX_VALUE); } } return super.isCoercibleTo(targetType, value); }