task2/solution11/src/org/apidesign/apifest08/currency/Computer.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 01 Oct 2008 10:43:05 +0200
changeset 29 f6073056b9fe
parent 6 task1/solution11/src/org/apidesign/apifest08/currency/Computer.java@97662396c0fd
permissions -rw-r--r--
Getting ready for task2: copying all solutions to new locations
     1 package org.apidesign.apifest08.currency;
     2 
     3 /**
     4  * Interface declaring method for computing conversion.
     5  * 
     6  * Because of a vague definition of currency amount's type,
     7  * the interface has a generic type.
     8  * 
     9  * @author ked
    10  * @see http://wiki.apidesign.org/wiki/APIDesignPatterns:ResponseReply
    11  */
    12 interface Computer<AmountType> {
    13 
    14     ComputerResponse<AmountType> compute(ComputerRequest<AmountType> request);
    15 
    16     /**
    17      * 
    18      * @param <AmountType>
    19      */
    20     final class ComputerRequest<AmountType> {
    21 
    22         private AmountType input;
    23         private AmountType inputCurrencyRatio;
    24         private AmountType outputCurrencyRatio;
    25 
    26         AmountType getInput() {
    27             return input;
    28         }
    29 
    30         void setInput(AmountType input) {
    31             this.input = input;
    32         }
    33 
    34         AmountType getInputCurrencyRatio() {
    35             return inputCurrencyRatio;
    36         }
    37 
    38         void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
    39             this.inputCurrencyRatio = inputCurrencyRatio;
    40         }
    41 
    42         AmountType getOutputCurrencyRatio() {
    43             return outputCurrencyRatio;
    44         }
    45 
    46         void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
    47             this.outputCurrencyRatio = outputCurrencyRatio;
    48         }
    49     }
    50 
    51     final class ComputerResponse<AmountType> {
    52 
    53         private AmountType result;
    54 
    55         AmountType getResult() {
    56             return result;
    57         }
    58 
    59         void setResult(AmountType result) {
    60             this.result = result;
    61         }
    62     }
    63     
    64     
    65 }