Commodity implements Serializable { public static Commodity getByExchangeSymbol( String symbol ) { for( Commodity commodity : ALL ) { if( commodity.getExchangeSymbol().equalsIgnoreCase(symbol) ) { return commodity; } } throw new IllegalStateException( "No Commodity found for symbol: " + symbol ); } Commodity(String exchangeSymbol, Exchange exchange, DecimalFormat decimalFormat, BigDecimal minimumTickSize, BigDecimal contractMultiplier );  Commodity(String exchangeSymbol, Exchange exchange, DecimalFormat decimalFormat, BigDecimal minimumTickSize, BigDecimal contractMultiplier, String currency); String getExchangeSymbol(); Exchange getExchange(); DecimalFormat getDecimalFormat(); BigDecimal getMinimumTickSize(); BigDecimal getContractMultiplier(); String getCurrency(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Commodity getByExchangeSymbol( String symbol ); static BigDecimal createBd(double value, int decimals); static final long serialVersionUID; static final DecimalFormat NO_DECIMALS; static final DecimalFormat ONE_DECIMAL; static final DecimalFormat TWO_DECIMALS; static final DecimalFormat THREE_DECIMALS; static final DecimalFormat FOUR_DECIMALS; static final DecimalFormat FIVE_DECIMALS; static final DecimalFormat SIX_DECIMALS; static final Commodity SP500_INDEX_MINI_GLOBEX; static final Commodity NASDAQ100_INDEX_MINI_GLOBEX; static final Commodity RUSSELL_2000_INDEX_MINI_NYBOT; static final Commodity RUSSELL_2000_INDEX_MINI_GLOBEX; static final Commodity DOW_INDEX_MINI_ECBOT; static final Commodity VIX_FUTURES_CFE; static final Commodity BOND_30_YEAR_ECBOT; static final Commodity BOND_10_YEAR_ECBOT; static final Commodity EURO_GLOBEX; static final Commodity EURO_MINI_GLOBEX; static final Commodity SWISS_FRANC_GLOBEX; static final Commodity JAPANESE_YEN_GLOBEX; static final Commodity JAPANESE_YEN_MINI_GLOBEX; static final Commodity CANADIAN_DOLLAR_GLOBEX; static final Commodity GOLD_NYMEX; static final Commodity GOLD_MINI_NYSE_LIFFE; static final Commodity SILVER_NYMEX; static final Commodity SILVER_MINI_NYSE_LIFFE; static final Commodity COPPER_NYMEX; static final Commodity CRUDE_OIL_NYMEX; static final Commodity CRUDE_OIL_MINI_NYMEX; static final Commodity NATURAL_GAS_NYMEX; static final Commodity NATURAL_GAS_MINI_NYMEX; static final Commodity HEATING_OIL_NYMEX; static final Commodity CORN_ECBOT; static final Commodity SOYBEANS_ECBOT; static final Commodity WHEAT_ECBOT; static final Commodity HANG_SENG_INDEX; static final Commodity HANG_SENG_MINI_INDEX; static final Commodity[] ALL; }
@Test public void testGetByExchangeSymbol() { assertEquals( Commodity.WHEAT_ECBOT, Commodity.getByExchangeSymbol("ZW")); }
@Test public void testGetByExchangeSymbol_SymbolNotFound() { try { Commodity.getByExchangeSymbol("Foo"); fail(); } catch( IllegalStateException ex ) { } }