TradeReferenceLine { protected Direction parseDirection( String dir ) { if( "Long".equalsIgnoreCase(dir) ) { return Direction.LONG; } else if( "Short".equalsIgnoreCase(dir) ) { return Direction.SHORT; } else { throw new IllegalStateException( "Unknown Direction: " + dir ); } }  static TradeReferenceLine create( String strategy, Direction direction, Side side ); static TradeReferenceLine createEntryLine( String strategy, Direction direction ); static TradeReferenceLine createExitLine( String strategy, Direction direction, String correlationId); static TradeReferenceLine createEntryLine( String strategy, Direction direction, String additionalInfo ); static TradeReferenceLine create( String strategy, Direction direction, Side side, String additionalInfo ); static TradeReferenceLine parseLine( String referenceLine ); void parse( String referenceLine ); String getStrategy(); TradeReferenceLine setStrategy(String strategy); String getCorrelationId(); TradeReferenceLine setCorrelationId(String correlationId); Direction getDirection(); TradeReferenceLine setDirection(Direction direction); Side getSide(); TradeReferenceLine setSide(Side side); String getAdditionalInfo(); void setAdditionalInfo(String additionalInfo); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final long serialVersionUID; }
@Test public void testParseDirection() { assertEquals(testLine.parseDirection("Long"), LONG); assertEquals(testLine.parseDirection("Short"), SHORT); try { testLine.parseDirection("foo"); fail(); } catch( IllegalStateException ex ) { } }