@Test public void testToNullDefaultValue() throws Exception { config.setNullFillerChar((char)0); config.setDefaultValue("42.00"); typeConverter.initialize(config); assertEquals(new BigDecimal("42.00"), typeConverter.to(new byte[4], 0, 2, 2, true)); }
@Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return new BigDecimal(defaultValue); } else { return new BigDecimal(new BigInteger(getString(bytes, offset, length, removePadding, 1)), decimals); } }
DecimalToBigDecimal extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return new BigDecimal(defaultValue); } else { return new BigDecimal(new BigInteger(getString(bytes, offset, length, removePadding, 1)), decimals); } } }
DecimalToBigDecimal extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return new BigDecimal(defaultValue); } else { return new BigDecimal(new BigInteger(getString(bytes, offset, length, removePadding, 1)), decimals); } }  }
DecimalToBigDecimal extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return new BigDecimal(defaultValue); } else { return new BigDecimal(new BigInteger(getString(bytes, offset, length, removePadding, 1)), decimals); } }  @Override void validate(Class<?> type, int size, int decimals); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding); }
DecimalToBigDecimal extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return new BigDecimal(defaultValue); } else { return new BigDecimal(new BigInteger(getString(bytes, offset, length, removePadding, 1)), decimals); } }  @Override void validate(Class<?> type, int size, int decimals); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding);  }