View Javadoc
1   package org.oxerr.viagogo.model;
2   
3   import java.io.Serializable;
4   import java.math.BigDecimal;
5   
6   import javax.annotation.Nullable;
7   
8   import org.apache.commons.lang3.builder.EqualsBuilder;
9   import org.apache.commons.lang3.builder.HashCodeBuilder;
10  
11  /**
12   * Returned for monetary values, such as ticket prices, fees charged and tax amounts.
13   *
14   * <a href="https://developer.viagogo.net/api-reference/catalog#tag/BasicType_Money">Money</a>
15   */
16  public class Money implements Serializable {
17  
18  	private static final long serialVersionUID = 2023021301L;
19  
20  	/**
21  	 * The decimal amount of the money.
22  	 */
23  	@Nullable
24  	private BigDecimal amount;
25  
26  	/**
27  	 * The ISO 4217 currency code that the monetary value is represented in.
28  	 */
29  	private String currencyCode;
30  
31  	/**
32  	 * A user-friendly string representing the monetary value.
33  	 */
34  	private String display;
35  
36  	public static Money of(String amount, String currencyCode) {
37  		return new Money(new BigDecimal(amount), currencyCode, null);
38  	}
39  
40  	public Money() {
41  	}
42  
43  	public Money(BigDecimal amount, String currencyCode, String display) {
44  		this.amount = amount;
45  		this.currencyCode = currencyCode;
46  		this.display = display;
47  	}
48  
49  	public BigDecimal getAmount() {
50  		return amount;
51  	}
52  
53  	public void setAmount(BigDecimal amount) {
54  		this.amount = amount;
55  	}
56  
57  	public String getCurrencyCode() {
58  		return currencyCode;
59  	}
60  
61  	public void setCurrencyCode(String currencyCode) {
62  		this.currencyCode = currencyCode;
63  	}
64  
65  	public String getDisplay() {
66  		return display;
67  	}
68  
69  	public void setDisplay(String display) {
70  		this.display = display;
71  	}
72  
73  	@Override
74  	public int hashCode() {
75  		return HashCodeBuilder.reflectionHashCode(this);
76  	}
77  
78  	@Override
79  	public boolean equals(Object obj) {
80  		if (obj == null) {
81  			return false;
82  		}
83  		if (obj == this) {
84  			return true;
85  		}
86  		if (obj.getClass() != getClass()) {
87  			return false;
88  		}
89  		Money rhs = (Money) obj;
90  		return EqualsBuilder.reflectionEquals(this, rhs);
91  	}
92  
93  	@Override
94  	public String toString() {
95  		return this.display;
96  	}
97  
98  }