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.math.BigDecimal;
20
21 import javax.persistence.Entity;
22 import javax.persistence.Id;
23 import javax.persistence.Table;
24
25 @Entity
26 @Table(name = "CUSTOMER")
27 public class CustomerCredit {
28
29 @Id
30 private int id;
31
32 private String name;
33
34 private BigDecimal credit;
35
36 public CustomerCredit() {
37 }
38
39 public CustomerCredit(int id, String name, BigDecimal credit) {
40 this.id = id;
41 this.name = name;
42 this.credit = credit;
43 }
44
45 public String toString() {
46 return "CustomerCredit [id=" + id + ",name=" + name + ", credit=" + credit + "]";
47 }
48
49 public BigDecimal getCredit() {
50 return credit;
51 }
52
53 public int getId() {
54 return id;
55 }
56
57 public void setId(int id) {
58 this.id = id;
59 }
60
61 public void setCredit(BigDecimal credit) {
62 this.credit = credit;
63 }
64
65 public String getName() {
66 return name;
67 }
68
69 public void setName(String name) {
70 this.name = name;
71 }
72
73 public CustomerCredit increaseCreditBy(BigDecimal sum) {
74 CustomerCredit newCredit = new CustomerCredit();
75 newCredit.credit = this.credit.add(sum);
76 newCredit.name = this.name;
77 newCredit.id = this.id;
78 return newCredit;
79 }
80
81 public boolean equals(Object o) {
82 return (o instanceof CustomerCredit) && ((CustomerCredit) o).id == id;
83 }
84
85 public int hashCode() {
86 return id;
87 }
88
89 }