task4/solution11/src/org/apidesign/apifest08/currency/Computer.java
changeset 61 58ec6da75f6f
parent 53 09d690bb97f6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/task4/solution11/src/org/apidesign/apifest08/currency/Computer.java	Sat Oct 11 23:38:46 2008 +0200
     1.3 @@ -0,0 +1,61 @@
     1.4 +package org.apidesign.apifest08.currency;
     1.5 +
     1.6 +/**
     1.7 + * Interface declaring method for computing conversion.
     1.8 + * 
     1.9 + * Because of a vague definition of currency amount's type,
    1.10 + * the interface has a generic type.
    1.11 + * 
    1.12 + * @author ked
    1.13 + * @see http://wiki.apidesign.org/wiki/APIDesignPatterns:ResponseReply
    1.14 + */
    1.15 +interface Computer<AmountType> {
    1.16 +
    1.17 +    void compute(ComputerRequest<AmountType> request, ComputerResponse<AmountType> response);
    1.18 +
    1.19 +    final class ComputerRequest<AmountType> {
    1.20 +
    1.21 +        private AmountType input;
    1.22 +        private AmountType inputCurrencyRatio;
    1.23 +        private AmountType outputCurrencyRatio;
    1.24 +
    1.25 +        AmountType getInput() {
    1.26 +            return input;
    1.27 +        }
    1.28 +
    1.29 +        void setInput(AmountType input) {
    1.30 +            this.input = input;
    1.31 +        }
    1.32 +
    1.33 +        AmountType getInputCurrencyRatio() {
    1.34 +            return inputCurrencyRatio;
    1.35 +        }
    1.36 +
    1.37 +        void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
    1.38 +            this.inputCurrencyRatio = inputCurrencyRatio;
    1.39 +        }
    1.40 +
    1.41 +        AmountType getOutputCurrencyRatio() {
    1.42 +            return outputCurrencyRatio;
    1.43 +        }
    1.44 +
    1.45 +        void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
    1.46 +            this.outputCurrencyRatio = outputCurrencyRatio;
    1.47 +        }
    1.48 +    }
    1.49 +
    1.50 +    final class ComputerResponse<AmountType> {
    1.51 +
    1.52 +        private AmountType result;
    1.53 +
    1.54 +        AmountType getResult() {
    1.55 +            return result;
    1.56 +        }
    1.57 +
    1.58 +        void setResult(AmountType result) {
    1.59 +            this.result = result;
    1.60 +        }
    1.61 +    }
    1.62 +    
    1.63 +    
    1.64 +}
    1.65 \ No newline at end of file