Guest User

Untitled

a guest
Jul 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package com.example.demo.model;
  2.  
  3. import org.springframework.data.annotation.Id;
  4. import org.springframework.data.mongodb.core.mapping.Document;
  5.  
  6. import javax.validation.constraints.NotBlank;
  7. import javax.validation.constraints.NotNull;
  8. import java.time.LocalDate;
  9.  
  10. @Document(collection = "books")
  11. public class Book {
  12.  
  13. @Id
  14. private String isbn;
  15.  
  16. @NotBlank
  17. private String title;
  18.  
  19. @NotNull
  20. LocalDate publicationDate;
  21.  
  22. public String getIsbn() {
  23. return isbn;
  24. }
  25.  
  26. public void setIsbn(String isbn) {
  27. this.isbn = isbn;
  28. }
  29.  
  30. public String getTitle() {
  31. return title;
  32. }
  33.  
  34. public void setTitle(String title) {
  35. this.title = title;
  36. }
  37.  
  38. public LocalDate getPublicationDate() {
  39. return publicationDate;
  40. }
  41.  
  42. public void setPublicationDate(LocalDate publicationDate) {
  43. this.publicationDate = publicationDate;
  44. }
  45.  
  46. @Override
  47. public boolean equals(Object o) {
  48. if (this == o) return true;
  49. if (o == null || getClass() != o.getClass()) return false;
  50.  
  51. Book book = (Book) o;
  52.  
  53. return isbn != null ? isbn.equals(book.isbn) : book.isbn == null;
  54. }
  55.  
  56. @Override
  57. public int hashCode() {
  58. return isbn != null ? isbn.hashCode() : 0;
  59. }
  60. }
Add Comment
Please, Sign In to add comment