View Javadoc
1   package org.oxerr.chbtc.dto;
2   
3   import java.io.UnsupportedEncodingException;
4   import java.math.BigDecimal;
5   import java.net.URLDecoder;
6   
7   import com.fasterxml.jackson.annotation.JsonProperty;
8   
9   public class Balance extends BaseObject {
10  
11  	private static final long serialVersionUID = 2014063001L;
12  
13  	/**
14  	 * 货币标识。
15  	 */
16  	private final String currency;
17  
18  	/**
19  	 * 货币符号。
20  	 */
21  	private final String symbol;
22  
23  	/**
24  	 * 货币总量。
25  	 */
26  	private final BigDecimal amount;
27  
28  	/**
29  	 * Constructor.
30  	 *
31  	 * @param currency the currency symbol.
32  	 * @param symbol the URL encoded currency symbol.
33  	 * @param amount the amount of the currency.
34  	 */
35  	public Balance(
36  			@JsonProperty("currency") final String currency,
37  			@JsonProperty("symbol") final String symbol,
38  			@JsonProperty("amount") final BigDecimal amount) {
39  		this.currency = currency;
40  		try {
41  			this.symbol = URLDecoder.decode(symbol, "UTF-8");
42  		} catch (UnsupportedEncodingException e) {
43  			throw new RuntimeException(e);
44  		}
45  		this.amount = amount;
46  	}
47  
48  	/**
49  	 * The currency code, e.g. CNY, BTC, LTC.
50  	 * 
51  	 * @return the currency
52  	 */
53  	public String getCurrency() {
54  		return currency;
55  	}
56  
57  	/**
58  	 * Returns currency symbol, e.g. ¥ for CNY, ฿ for BTC, Ł for LTC.
59  	 * 
60  	 * @return the currency symbol.
61  	 */
62  	public String getSymbol() {
63  		return symbol;
64  	}
65  
66  	/**
67  	 * Balance amount.
68  	 * 
69  	 * @return The balance amount.
70  	 */
71  	public BigDecimal getAmount() {
72  		return amount;
73  	}
74  
75  }