@Override public int compareTo(Currency o2) { Currency o1 = this; if(o2==null){ //throw new NullPointerException("compareTo invalid for null objects in Currency.compareTo"); return 1; // prefer to say this object is always greater than a null? } int symbolComp = o1.getSymbol().compareTo(o2.getSymbol()); if(symbolComp==0){ int nearTenorComp = o1.getNearTenor().compareTo(o2.getNearTenor()); if(nearTenorComp==0){ if(o1.isSwap() && o2.isSwap()){ return o1.getFarTenor().compareTo(o2.getFarTenor()); }else{ return 0; } }else{ return nearTenorComp; } }else{ return symbolComp; } }
@Override public void validate(Instrument inInstrument) throws OrderValidationException { Currency currency = (Currency) inInstrument; validateCurrencySymbol(currency.getSymbol()); if(currency.getNearTenor() !=null && !currency.getNearTenor().isEmpty()) { validateTenor(currency.getNearTenor()); } if(currency.getFarTenor() !=null && !currency.getFarTenor().isEmpty()) { validateTenor(currency.getFarTenor()); } }
} else if(instrument instanceof Currency) { Currency currency = (Currency)instrument; positionKey = PositionKeyFactory.createCurrencyKey(currency.getSymbol(), rpcAccount, rpcTraderId);