1 package org.apidesign.apifest08.currency;
4 * Interface declaring method for computing conversion.
6 * Because of a vague definition of currency amount's type,
7 * the interface has a generic type.
10 * @see http://wiki.apidesign.org/wiki/APIDesignPatterns:ResponseReply
12 interface Computer<AmountType> {
14 void compute(ComputerRequest<AmountType> request, ComputerResponse<AmountType> response);
16 final class ComputerRequest<AmountType> {
18 private AmountType input;
19 private AmountType inputCurrencyRatio;
20 private AmountType outputCurrencyRatio;
22 AmountType getInput() {
26 void setInput(AmountType input) {
30 AmountType getInputCurrencyRatio() {
31 return inputCurrencyRatio;
34 void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
35 this.inputCurrencyRatio = inputCurrencyRatio;
38 AmountType getOutputCurrencyRatio() {
39 return outputCurrencyRatio;
42 void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
43 this.outputCurrencyRatio = outputCurrencyRatio;
47 final class ComputerResponse<AmountType> {
49 private AmountType result;
51 AmountType getResult() {
55 void setResult(AmountType result) {