-
Notifications
You must be signed in to change notification settings - Fork 76
/
Loan.java
executable file
·77 lines (62 loc) · 1.69 KB
/
Loan.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package io.pivotal.loansource;
import java.util.Objects;
/**
* This class defines a loan. It is associated with an applicant, has an amount, and a status.
*/
public class Loan {
private String uuid, name, status;
private long amount;
public Loan() {
}
public Loan(String uuid, String name, long amount) {
this.uuid = uuid;
this.name = name;
this.amount = amount;
this.setStatus(Statuses.PENDING.name());
}
public String getUuid() {
return uuid;
}
public String getName() {
return name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
if (status.equals(Statuses.APPROVED.name())
|| status.equals(Statuses.DECLINED.name())
|| status.equals(Statuses.PENDING.name())
|| status.equals(Statuses.REJECTED.name())) {
this.status = status;
} else {
throw new IllegalArgumentException("Cannot set the LoanApplication's status to " + status);
}
}
public long getAmount() {
return amount;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Loan that = (Loan) o;
return amount == that.amount &&
uuid.equals(that.uuid) &&
name.equals(that.name) &&
Objects.equals(status, that.status);
}
@Override
public int hashCode() {
return Objects.hash(uuid, name, status, amount);
}
@Override
public String toString() {
return "Loan{" +
"uuid='" + uuid + '\'' +
", name='" + name + '\'' +
", status='" + status + '\'' +
", amount=" + amount +
'}';
}
}