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
japod@6
     1
package org.apidesign.apifest08.currency;
japod@6
     2
japod@6
     3
/**
japod@6
     4
 * Interface declaring method for computing conversion.
japod@6
     5
 * 
japod@6
     6
 * Because of a vague definition of currency amount's type,
japod@6
     7
 * the interface has a generic type.
japod@6
     8
 * 
japod@6
     9
 * @author ked
japod@6
    10
 * @see http://wiki.apidesign.org/wiki/APIDesignPatterns:ResponseReply
japod@6
    11
 */
japod@6
    12
interface Computer<AmountType> {
japod@6
    13
japod@53
    14
    void compute(ComputerRequest<AmountType> request, ComputerResponse<AmountType> response);
japod@6
    15
japod@6
    16
    final class ComputerRequest<AmountType> {
japod@6
    17
japod@6
    18
        private AmountType input;
japod@6
    19
        private AmountType inputCurrencyRatio;
japod@6
    20
        private AmountType outputCurrencyRatio;
japod@6
    21
japod@6
    22
        AmountType getInput() {
japod@6
    23
            return input;
japod@6
    24
        }
japod@6
    25
japod@6
    26
        void setInput(AmountType input) {
japod@6
    27
            this.input = input;
japod@6
    28
        }
japod@6
    29
japod@6
    30
        AmountType getInputCurrencyRatio() {
japod@6
    31
            return inputCurrencyRatio;
japod@6
    32
        }
japod@6
    33
japod@6
    34
        void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
japod@6
    35
            this.inputCurrencyRatio = inputCurrencyRatio;
japod@6
    36
        }
japod@6
    37
japod@6
    38
        AmountType getOutputCurrencyRatio() {
japod@6
    39
            return outputCurrencyRatio;
japod@6
    40
        }
japod@6
    41
japod@6
    42
        void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
japod@6
    43
            this.outputCurrencyRatio = outputCurrencyRatio;
japod@6
    44
        }
japod@6
    45
    }
japod@6
    46
japod@6
    47
    final class ComputerResponse<AmountType> {
japod@6
    48
japod@6
    49
        private AmountType result;
japod@6
    50
japod@6
    51
        AmountType getResult() {
japod@6
    52
            return result;
japod@6
    53
        }
japod@6
    54
japod@6
    55
        void setResult(AmountType result) {
japod@6
    56
            this.result = result;
japod@6
    57
        }
japod@6
    58
    }
japod@6
    59
    
japod@6
    60
    
japod@6
    61
}