View Javadoc
1   package org.oxerr.chbtc.dto;
2   
3   public enum Type {
4   
5   	BUY(1, "buy"), SELL(0, "sell");
6   
7   	public static Type toType(String typeString) {
8   		for (Type type : Type.values()) {
9   			if (type.type.equals(typeString)) {
10  				return type;
11  			}
12  		}
13  
14  		throw new IllegalArgumentException("Unexpected type: " + typeString);
15  	}
16  
17  	public static Type toType(int tradeType) {
18  		for (Type type : Type.values()) {
19  			if (type.tradeType == tradeType) {
20  				return type;
21  			}
22  		}
23  
24  		throw new IllegalArgumentException("Unexpected trade type: " + tradeType);
25  	}
26  
27  	private int tradeType;
28  
29  	private String type;
30  
31  	Type(int tradeType, String type) {
32  		this.tradeType = tradeType;
33  		this.type = type;
34  	}
35  
36  	public int getTradeType() {
37  		return tradeType;
38  	}
39  
40  }