Skip to content

Aplicando Lombok nas classes ordinárias#55

Open
ElyonaySouza wants to merge 3 commits intomainfrom
user-book-loan-convert-lombok
Open

Aplicando Lombok nas classes ordinárias#55
ElyonaySouza wants to merge 3 commits intomainfrom
user-book-loan-convert-lombok

Conversation

@ElyonaySouza
Copy link
Collaborator

Foi necessário dar uma mexida no BookService e eu aproveitei e optei por essa forma maior de dispor dos argumentos. Acredito que fique mais legível e fluido no entendimento.

this.booksIds = booksIds;
this.loanDate = LocalDate.now();
this.expectedReturnDate = loanDate.plusDays(3);
this.expectedReturnDate = this.loanDate.plusDays(3);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que diferença fez o this e o Builder do topo? Tentou eliminar esse construtor pra fazer que nem fez com livro?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

É tipo uma ênfase pra evitar ambiguidade. As vezes eu gosto de colocar, pois o this vai driblar algum problema com variáveis ou parâmetros com o mesmo nome. Como tenho visto muitos conflitos aqui no Git, fiquei com medo de algo desse tipo.

Copy link
Owner

@gabrielvf64 gabrielvf64 Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isso é mais em javascript. É uma alteração única sendo que em todo projeto não tá nesse padrão e os objetos estão sendo construidos sem problema.

Pra embasar mais ainda, você está com medo de conflitos no git, essa alteração do this vai justamente causar conflito em todas as branchs já abertas porque está alterando algo que já existe.

Reverte pra ser coisa a menos pra ver.

E quanto ao Builder e tentar replicar o que fez no book?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isso mesmo!

@@ -39,11 +39,4 @@ public class Book {
@Enumerated(EnumType.STRING)
private BookStatus status = BookStatus.AVAILABLE;
Copy link
Collaborator

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.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants