task4/solution11/src/org/apidesign/apifest08/currency/Computer.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 11 Oct 2008 23:38:46 +0200
changeset 61 58ec6da75f6f
parent 53 task3/solution11/src/org/apidesign/apifest08/currency/Computer.java@09d690bb97f6
permissions -rw-r--r--
Copying structure for task4
     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     void compute(ComputerRequest<AmountType> request, ComputerResponse<AmountType> response);
    15 
    16     final class ComputerRequest<AmountType> {
    17 
    18         private AmountType input;
    19         private AmountType inputCurrencyRatio;
    20         private AmountType outputCurrencyRatio;
    21 
    22         AmountType getInput() {
    23             return input;
    24         }
    25 
    26         void setInput(AmountType input) {
    27             this.input = input;
    28         }
    29 
    30         AmountType getInputCurrencyRatio() {
    31             return inputCurrencyRatio;
    32         }
    33 
    34         void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
    35             this.inputCurrencyRatio = inputCurrencyRatio;
    36         }
    37 
    38         AmountType getOutputCurrencyRatio() {
    39             return outputCurrencyRatio;
    40         }
    41 
    42         void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
    43             this.outputCurrencyRatio = outputCurrencyRatio;
    44         }
    45     }
    46 
    47     final class ComputerResponse<AmountType> {
    48 
    49         private AmountType result;
    50 
    51         AmountType getResult() {
    52             return result;
    53         }
    54 
    55         void setResult(AmountType result) {
    56             this.result = result;
    57         }
    58     }
    59     
    60     
    61 }