1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.batch.sample.domain.trade;
18
19 import java.io.Serializable;
20 import java.math.BigDecimal;
21
22
23
24
25
26
27 public class Trade implements Serializable {
28 private String isin = "";
29 private long quantity = 0;
30 private BigDecimal price = new BigDecimal(0);
31 private String customer = "";
32 private Long id;
33 private long version = 0;
34
35 public Trade() {
36 }
37
38 public Trade(String isin, long quantity, BigDecimal price, String customer){
39 this.isin = isin;
40 this.quantity = quantity;
41 this.price = price;
42 this.customer = customer;
43 }
44
45
46
47
48 public Trade(long id) {
49 this.id = id;
50 }
51
52 public long getId() {
53 return id;
54 }
55
56 public void setId(long id) {
57 this.id = id;
58 }
59
60 public long getVersion() {
61 return version;
62 }
63
64 public void setVersion(long version) {
65 this.version = version;
66 }
67
68 public void setCustomer(String customer) {
69 this.customer = customer;
70 }
71
72 public void setIsin(String isin) {
73 this.isin = isin;
74 }
75
76 public void setPrice(BigDecimal price) {
77 this.price = price;
78 }
79
80 public void setQuantity(long quantity) {
81 this.quantity = quantity;
82 }
83
84 public String getIsin() {
85 return isin;
86 }
87
88 public BigDecimal getPrice() {
89 return price;
90 }
91
92 public long getQuantity() {
93 return quantity;
94 }
95
96 public String getCustomer() {
97 return customer;
98 }
99
100 public String toString() {
101 return "Trade: [isin=" + this.isin + ",quantity=" + this.quantity + ",price="
102 + this.price + ",customer=" + this.customer + "]";
103 }
104
105 @Override
106 public int hashCode() {
107 final int prime = 31;
108 int result = 1;
109 result = prime * result + ((customer == null) ? 0 : customer.hashCode());
110 result = prime * result + ((isin == null) ? 0 : isin.hashCode());
111 result = prime * result + ((price == null) ? 0 : price.hashCode());
112 result = prime * result + (int) (quantity ^ (quantity >>> 32));
113 result = prime * result + (int) (version ^ (version >>> 32));
114 return result;
115 }
116
117 @Override
118 public boolean equals(Object obj) {
119 if (this == obj)
120 return true;
121 if (obj == null)
122 return false;
123 if (getClass() != obj.getClass())
124 return false;
125 Trade other = (Trade) obj;
126 if (customer == null) {
127 if (other.customer != null)
128 return false;
129 }
130 else if (!customer.equals(other.customer))
131 return false;
132 if (isin == null) {
133 if (other.isin != null)
134 return false;
135 }
136 else if (!isin.equals(other.isin))
137 return false;
138 if (price == null) {
139 if (other.price != null)
140 return false;
141 }
142 else if (!price.equals(other.price))
143 return false;
144 if (quantity != other.quantity)
145 return false;
146 if (version != other.version)
147 return false;
148 return true;
149 }
150
151 }