task2/solution13/src/org/apidesign/apifest08/currency/ConversionResult.java
author japod@localhost
Tue, 07 Oct 2008 01:18:23 +0200
changeset 41 a7e6f84fb078
parent 29 f6073056b9fe
permissions -rw-r--r--
adding solution13 for task2
     1 
     2 package org.apidesign.apifest08.currency;
     3 
     4 import java.math.BigDecimal;
     5 
     6 /**
     7  * Result of currency conversion. Holds converted value and remainder.
     8  * <p>
     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.
    12  * 
    13  * @author arnostvalicek
    14  */
    15 public class ConversionResult {
    16     private BigDecimal converted;
    17     private BigDecimal remainder;
    18     
    19     /**
    20      * Get converted value.
    21      * @return Returns converted value.
    22      */
    23     public BigDecimal getConverted() {
    24         return converted;
    25     }
    26 
    27     void setConverted(BigDecimal converted) {
    28         this.converted = converted;
    29     }
    30 
    31     
    32     /**
    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>
    35      * <p>
    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.
    38      * 
    39      * @return Returns remainder of conversion.
    40      */
    41     public BigDecimal getRemainder() {
    42         return remainder;
    43     }
    44 
    45     void setRemainder(BigDecimal remainder) {
    46         this.remainder = remainder;
    47     }
    48 
    49 }