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 ComputerResponse<AmountType> compute(ComputerRequest<AmountType> request);
20 final class ComputerRequest<AmountType> {
22 private AmountType input;
23 private AmountType inputCurrencyRatio;
24 private AmountType outputCurrencyRatio;
26 AmountType getInput() {
30 void setInput(AmountType input) {
34 AmountType getInputCurrencyRatio() {
35 return inputCurrencyRatio;
38 void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
39 this.inputCurrencyRatio = inputCurrencyRatio;
42 AmountType getOutputCurrencyRatio() {
43 return outputCurrencyRatio;
46 void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
47 this.outputCurrencyRatio = outputCurrencyRatio;
51 final class ComputerResponse<AmountType> {
53 private AmountType result;
55 AmountType getResult() {
59 void setResult(AmountType result) {