-
Notifications
You must be signed in to change notification settings - Fork 1
Aplicando Lombok nas classes ordinárias #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,16 @@ | ||
| package com.box.library.loan; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| @Entity | ||
| @Table(name = "loans") | ||
| public class Loan { | ||
|
|
@@ -22,70 +28,13 @@ public class Loan { | |
| private LocalDate returnDate; | ||
| private LoanStatus status; | ||
|
|
||
| public Loan() { | ||
| } | ||
|
|
||
| @Builder | ||
| public Loan(Long userId, List<Long> booksIds) { | ||
| this.userId = userId; | ||
| this.booksIds = booksIds; | ||
| this.loanDate = LocalDate.now(); | ||
| this.expectedReturnDate = loanDate.plusDays(3); | ||
| this.expectedReturnDate = this.loanDate.plusDays(3); | ||
|
||
| this.status = LoanStatus.ACTIVE; | ||
| } | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(Long id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public Long getUserId() { | ||
| return userId; | ||
| } | ||
|
|
||
| public void setUserId(Long userId) { | ||
| this.userId = userId; | ||
| } | ||
|
|
||
| public List<Long> getBooksIds() { | ||
| return booksIds; | ||
| } | ||
|
|
||
| public void setBooksIds(List<Long> booksIds) { | ||
| this.booksIds = booksIds; | ||
| } | ||
|
|
||
| public LocalDate getLoanDate() { | ||
| return loanDate; | ||
| } | ||
|
|
||
| public void setLoanDate(LocalDate loanDate) { | ||
| this.loanDate = loanDate; | ||
| } | ||
|
|
||
| public LocalDate getExpectedReturnDate() { | ||
| return expectedReturnDate; | ||
| } | ||
|
|
||
| public void setExpectedReturnDate(LocalDate expectedReturnDate) { | ||
| this.expectedReturnDate = expectedReturnDate; | ||
| } | ||
|
|
||
| public LocalDate getReturnDate() { | ||
| return returnDate; | ||
| } | ||
|
|
||
| public void setReturnDate(LocalDate returnDate) { | ||
| this.returnDate = returnDate; | ||
| } | ||
|
|
||
| public LoanStatus getStatus() { | ||
| return status; | ||
| } | ||
|
|
||
| public void setStatus(LoanStatus status) { | ||
| this.status = status; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fala jovem, estou levando uma exception ao criar o livro, aparentemente está tentando colocar null no status.
Acredito que esteja faltando a anotação para dizer que o status é aquele padrão available.
Se eu não me engano a annotation é "@Builder.Default". Depois dá um confere ae pfv.