BigDecimalCoder extends AtomicCoder<BigDecimal> { @Override protected long getEncodedElementByteSize(BigDecimal value) throws Exception { checkNotNull(value, String.format("cannot encode a null %s", BigDecimal.class.getSimpleName())); return VAR_INT_CODER.getEncodedElementByteSize(value.scale()) + BIG_INT_CODER.getEncodedElementByteSize(value.unscaledValue()); } private  BigDecimalCoder(); static BigDecimalCoder of(); @Override void encode(BigDecimal value, OutputStream outStream); @Override void encode(BigDecimal value, OutputStream outStream, Context context); @Override BigDecimal decode(InputStream inStream); @Override BigDecimal decode(InputStream inStream, Context context); @Override void verifyDeterministic(); @Override boolean consistentWithEquals(); @Override boolean isRegisterByteSizeObserverCheap(BigDecimal value);  }
@Test public void testGetEncodedElementByteSize() throws Exception { TestElementByteSizeObserver observer = new TestElementByteSizeObserver(); for (BigDecimal value : TEST_VALUES) { TEST_CODER.registerByteSizeObserver(value, observer); observer.advance(); assertThat( observer.getSumAndReset(), equalTo( (long) CoderUtils.encodeToByteArray(TEST_CODER, value, Coder.Context.NESTED).length)); } }