FuturesTicker extends Ticker { public static FuturesTicker getInstance(String exchangeSymbol) { FuturesTicker ticker = null; for (Commodity commodity : Commodity.ALL) { if (exchangeSymbol.equals(commodity.getExchangeSymbol())) { ticker = getInstance(commodity); } } if (ticker == null) { throw new IllegalStateException("Ticker not found for exchange symbol " + exchangeSymbol); } return ticker; }  Commodity getCommodity(); FuturesTicker setCommodity(Commodity commodity); @Override InstrumentType getInstrumentType(); int getExpiryMonth(); FuturesTicker setExpiryMonth(int expiryMonth); int getExpiryYear(); FuturesTicker setExpiryYear(int expiryYear); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static FuturesTicker getInstance(String exchangeSymbol); static FuturesTicker getInstance(Commodity commodity); static FuturesTicker getInstance(Commodity commodity, int expirationMonth, int expirationYear); final static long serialVersionUID; }
@Test public void testGetInstance() { int experiationMonth = 12; int expirationYear = 2014; FuturesTicker expected = new FuturesTicker(); expected.setSymbol("ES"); expected.setExpiryMonth(experiationMonth); expected.setExpiryYear(expirationYear); expected.setExchange(Exchange.GLOBEX); expected.setDecimalFormat( Commodity.TWO_DECIMALS ); expected.setMinimumTickSize( new BigDecimal( 0.25 )); expected.setContractMultiplier( new BigDecimal(50) ); expected.setCommodity(SP500_INDEX_MINI_GLOBEX); assertEquals(expected, FuturesTicker.getInstance(SP500_INDEX_MINI_GLOBEX, experiationMonth, expirationYear)); }