japod@23:
japod@23: package org.apidesign.apifest08.currency;
japod@23:
japod@23: import java.math.BigDecimal;
japod@23:
japod@23: /**
japod@23: * Exchange rate value. Contains from
and to
value.
japod@23: *
japod@23: * @author arnostvalicek
japod@23: */
japod@23: public class ExchangeRate {
japod@23: private BigDecimal numberFor;
japod@23: private BigDecimal numberGet;
japod@23:
japod@41: /**
japod@41: * Constructor for new exchange rate holding two values - from value and to value
japod@41: * @param fromValue Exchange rate from value
japod@41: * @param toValue Exchange rate to value
japod@41: */
japod@23: public ExchangeRate(BigDecimal fromValue, BigDecimal toValue) {
japod@23: this.numberFor = fromValue;
japod@23: this.numberGet = toValue;
japod@23: }
japod@41:
japod@41: /**
japod@41: * Create new instance of ExchangeRate
based on provided exchange rate, but swapping its
japod@41: * from and to value.
japod@41: *
japod@41: * Provided exchange rate is not chaged, this method returns different instance describing reverted exchange rate. japod@41: * japod@41: * @param rate Exchange rate which describes rate to be reverted. japod@41: * @return Instance of reverted rate. japod@41: */ japod@41: public static ExchangeRate createRevertedRate(ExchangeRate rate) { japod@41: ExchangeRate reverted = new ExchangeRate(rate.getToValue(), rate.getFromValue()); japod@41: return reverted; japod@41: } japod@23: japod@23: @Override japod@23: public String toString() { japod@23: return "for "+numberFor+" recieve "+numberGet+" @"+getClass().getName(); japod@23: } japod@23: japod@41: /** japod@41: * Return exchange rate from value stored in this object. japod@41: * @return Returns from value for this exchange rate. japod@41: */ japod@23: public BigDecimal getFromValue() { japod@23: return numberFor; japod@23: } japod@23: japod@41: /** japod@41: * Return exchange rate to value stored in this object. japod@41: * @return Returns to value for this exchange rate. japod@41: */ japod@23: public BigDecimal getToValue() { japod@23: return numberGet; japod@23: } japod@23: japod@23: japod@23: // public ExchangeRate createExchangeRate(BigDecimal forValue, BigDecimal getValue) { japod@23: // ExchangeRate rate = new ExchangeRate(forValue, getValue); japod@23: // return rate; japod@23: // } japod@23: japod@23: japod@23: japod@23: }