StudentLoanManagement
Loan.java
Go to the documentation of this file.
1
2package com.student_loan.model;
3
4import jakarta.persistence.*;
5import java.util.Date;
6
10@Entity
11@Table(name = "loans")
12public class Loan {
13
17 @Id
18 @GeneratedValue(strategy = GenerationType.IDENTITY)
19 private Long id;
20
24 @Column(name = "lender_id", nullable = false)
25 private Long lender;
26
30 @Column(name = "borrower_id", nullable = false)
31 private Long borrower;
32
36 @Column(name = "item_id", nullable = false)
37 private Long item;
38
42 @Temporal(TemporalType.DATE)
43 @Column(name = "loan_date", nullable = false)
44 private Date loanDate;
45
49 @Temporal(TemporalType.DATE)
50 @Column(name = "estimated_return_date")
51 private Date estimatedReturnDate;
52
56 @Temporal(TemporalType.DATE)
57 @Column(name = "real_return_date")
58 private Date realReturnDate;
59
63 @Enumerated(EnumType.STRING)
64 @Column(name = "loan_status", nullable = false)
65 private Status loanStatus;
66
70 @Column(name = "rating")
71 private Double rating;
72
76 private String observations;
77
81 public enum Status {
82 IN_USE, RETURNED, DELAYED, LOST
83 }
84
88 public Loan() {
89 }
90
105 public Loan(Long id, Long lender, Long borrower, Long item, Date loanDate, Date estimatedReturnDate, Date realReturnDate, Status loanStatus, Double rating, String observations) {
106 this.id = id;
107 this.lender = lender;
108 this.borrower = borrower;
109 this.item = item;
110 this.loanDate = loanDate;
111 this.estimatedReturnDate = estimatedReturnDate;
112 this.realReturnDate = realReturnDate;
113 this.loanStatus = loanStatus;
114 this.rating = rating;
115 this.observations = observations;
116 }
117
123 public Long getId() {
124 return id;
125 }
126
132 public void setId(Long id) {
133 this.id = id;
134 }
135
141 public Long getLender() {
142 return lender;
143 }
144
150 public void setLender(Long lender) {
151 this.lender = lender;
152 }
153
159 public Long getBorrower() {
160 return borrower;
161 }
162
168 public void setBorrower(Long borrower) {
169 this.borrower = borrower;
170 }
171
177 public Long getItem() {
178 return item;
179 }
180
186 public void setItem(Long item) {
187 this.item = item;
188 }
189
195 public Date getLoanDate() {
196 return loanDate;
197 }
198
204 public void setLoanDate(Date loanDate) {
205 this.loanDate = loanDate;
206 }
207
214 if (estimatedReturnDate == null) {
215 return new Date();
216 }
217 return estimatedReturnDate;
218 }
219
225 public void setEstimatedReturnDate(Date estimatedReturnDate) {
226 this.estimatedReturnDate = estimatedReturnDate;
227 }
228
234 public Date getRealReturnDate() {
235 if (realReturnDate == null) {
236 return new Date();
237 }
238 return realReturnDate;
239 }
240
246 public void setRealReturnDate(Date realReturnDate) {
247 this.realReturnDate = realReturnDate;
248 }
249
256 return loanStatus;
257 }
258
264 public void setLoanStatus(Status loanStatus) {
265 this.loanStatus = loanStatus;
266 }
267
273 public Double getRating() {
274 return rating;
275 }
276
282 public void setRating(Double rating) {
283 this.rating = rating;
284 }
285
291 public String getObservations() {
292 return observations;
293 }
294
300 public void setObservations(String observations) {
301 this.observations = observations;
302 }
303
309 @Override
310 public String toString() {
311 return "Loan{" +
312 "id=" + id +
313 ", lender=" + lender +
314 ", borrower=" + borrower +
315 ", item=" + item +
316 ", loanDate=" + loanDate +
317 ", estimatedReturnDate=" + estimatedReturnDate +
318 ", realReturnDate=" + realReturnDate +
319 ", loanStatus=" + loanStatus +
320 ", rating=" + rating +
321 ", observations='" + observations + '\'' +
322 '}';
323 }
324}
325
void setEstimatedReturnDate(Date estimatedReturnDate)
Definition Loan.java:225
void setObservations(String observations)
Definition Loan.java:300
void setLoanDate(Date loanDate)
Definition Loan.java:204
void setRealReturnDate(Date realReturnDate)
Definition Loan.java:246
Loan(Long id, Long lender, Long borrower, Long item, Date loanDate, Date estimatedReturnDate, Date realReturnDate, Status loanStatus, Double rating, String observations)
Definition Loan.java:105
void setItem(Long item)
Definition Loan.java:186
void setLender(Long lender)
Definition Loan.java:150
void setBorrower(Long borrower)
Definition Loan.java:168
void setRating(Double rating)
Definition Loan.java:282
void setLoanStatus(Status loanStatus)
Definition Loan.java:264