2 package org.apidesign.apifest08.currency;
4 import java.math.BigDecimal;
7 * Result of currency conversion. Holds converted value and remainder.
9 * <em>Converted</em> describes value converted to <em>target</em> currenty. <em>Remainder</em> describes
10 * how much from original <em>amount</em> was not possible to convert. Convertor never loses any (small) money
11 * in conversion error (rounding), but instead of rounding is converts only as much as possible and keeps rest as remainder.
13 * @author arnostvalicek
15 public class ConversionResult {
16 private BigDecimal converted;
17 private BigDecimal remainder;
20 * Get converted value.
21 * @return Returns converted value.
23 public BigDecimal getConverted() {
27 void setConverted(BigDecimal converted) {
28 this.converted = converted;
33 * Get remainder of conversion. Remainder is set if part of converted amount which can't be converted
34 * because this target currency precision can't handle small numbers. Remainder value is in <em>from currency</em>
36 * Converter never loses any precision in conversion. Remainer describes how much of amount can't be converted.
37 * If we substract <em>remainder</em> from <em>amount</em> we will be able to get exact conversion.
39 * @return Returns remainder of conversion.
41 public BigDecimal getRemainder() {
45 void setRemainder(BigDecimal remainder) {
46 this.remainder = remainder;