@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 1477363453: // decimalPlaces return ((HalfUpRounding) bean).getDecimalPlaces(); case -1653751294: // fraction return ((HalfUpRounding) bean).getFraction(); } return super.propertyGet(bean, propertyName, quiet); }
public void test_ofFractionalDecimalPlaces() { HalfUpRounding test = HalfUpRounding.ofFractionalDecimalPlaces(4, 32); assertEquals(test.getDecimalPlaces(), 4); assertEquals(test.getFraction(), 32); assertEquals(test.toString(), "Round to 1/32 of 4dp"); assertEquals(Rounding.ofFractionalDecimalPlaces(4, 32), test); }
public void test_ofDecimalPlaces() { HalfUpRounding test = HalfUpRounding.ofDecimalPlaces(4); assertEquals(test.getDecimalPlaces(), 4); assertEquals(test.getFraction(), 0); assertEquals(test.toString(), "Round to 4dp"); assertEquals(Rounding.ofDecimalPlaces(4), test); }
public void test_ofDecimalPlaces_big() { HalfUpRounding test = HalfUpRounding.ofDecimalPlaces(40); assertEquals(test.getDecimalPlaces(), 40); assertEquals(test.getFraction(), 0); assertEquals(test.toString(), "Round to 40dp"); assertEquals(Rounding.ofDecimalPlaces(40), test); }
public void test_builder() { HalfUpRounding test = HalfUpRounding.meta().builder() .set(HalfUpRounding.meta().decimalPlaces(), 4) .set(HalfUpRounding.meta().fraction(), 1) .build(); assertEquals(test.getDecimalPlaces(), 4); assertEquals(test.getFraction(), 0); assertEquals(test.toString(), "Round to 4dp"); }