DefaultRateOfExchanges.java
package com.tradecloud.domain.exchangerate;
import com.tradecloud.domain.model.RateOfExchangeType;
import java.math.BigDecimal;
/**
* @author jon
*/
public class DefaultRateOfExchanges implements RateOfExchanges {
private BigDecimal spotRate;
private BigDecimal forwardRate;
public DefaultRateOfExchanges(BigDecimal spotRate, BigDecimal forwardRate) {
this.spotRate = spotRate;
this.forwardRate = forwardRate;
}
@Override
public BigDecimal getSpotRate() {
return spotRate;
}
@Override
public void setSpotRate(BigDecimal spotRate) {
this.spotRate = spotRate;
}
@Override
public BigDecimal getForwardRate() {
return forwardRate;
}
@Override
public void setForwardRate(BigDecimal forwardRate) {
this.forwardRate = forwardRate;
}
// TOOD. Put somewhere better
public static BigDecimal getRateOfExchange(RateOfExchanges rateOfExchanges, RateOfExchangeType rateOfExchangeType) {
switch (rateOfExchangeType) {
case SPOT:
return rateOfExchanges.getSpotRate();
case FORWARD:
return rateOfExchanges.getForwardRate();
default:
return null;
}
}
public static RateOfExchanges createUnity() {
return new DefaultRateOfExchanges(BigDecimal.ONE, BigDecimal.ONE);
}
}