|
1 | 1 | package com.howtoprogram.jsonpojo; |
2 | 2 |
|
| 3 | +import java.time.LocalDate; |
| 4 | +import java.util.Date; |
| 5 | + |
| 6 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 7 | + |
| 8 | +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; |
3 | 9 |
|
4 | 10 | public class Book { |
5 | 11 |
|
6 | | - private Long id; |
7 | | - private String name; |
8 | | - private String author; |
9 | | - |
10 | | - |
11 | | - public Book() { |
12 | | - super(); |
13 | | - } |
14 | | - |
15 | | - public Book(Long id, String name, String author) { |
16 | | - super(); |
17 | | - this.id = id; |
18 | | - this.name = name; |
19 | | - this.author = author; |
20 | | - } |
21 | | - |
22 | | - /** |
23 | | - * @return the id |
24 | | - */ |
25 | | - public Long getId() { |
26 | | - return id; |
27 | | - } |
28 | | - |
29 | | - /** |
30 | | - * @param id the id to set |
31 | | - */ |
32 | | - public void setId(Long id) { |
33 | | - this.id = id; |
34 | | - } |
35 | | - |
36 | | - /** |
37 | | - * @return the name |
38 | | - */ |
39 | | - public String getName() { |
40 | | - return name; |
41 | | - } |
42 | | - |
43 | | - /** |
44 | | - * @param name the name to set |
45 | | - */ |
46 | | - public void setName(String name) { |
47 | | - this.name = name; |
48 | | - } |
49 | | - |
50 | | - /** |
51 | | - * @return the author |
52 | | - */ |
53 | | - public String getAuthor() { |
54 | | - return author; |
55 | | - } |
56 | | - |
57 | | - /** |
58 | | - * @param author the author to set |
59 | | - */ |
60 | | - public void setAuthor(String author) { |
61 | | - this.author = author; |
62 | | - } |
63 | | - |
64 | | - /* |
65 | | - * (non-Javadoc) |
66 | | - * |
67 | | - * @see java.lang.Object#toString() |
68 | | - */ |
69 | | - @Override |
70 | | - public String toString() { |
71 | | - return "Book [id=" + id + ", name=" + name + ", author=" + author + "]"; |
72 | | - } |
| 12 | + private Long id; |
| 13 | + private String name; |
| 14 | + private String author; |
| 15 | + |
| 16 | + @JsonInclude(NON_NULL) |
| 17 | + private LocalDate pubDate; |
| 18 | + @JsonInclude(NON_NULL) |
| 19 | + private Date copyrightDate; |
| 20 | + |
| 21 | + public Book() { |
| 22 | + super(); |
| 23 | + } |
| 24 | + |
| 25 | + public Book(Long id, String name, String author) { |
| 26 | + super(); |
| 27 | + this.id = id; |
| 28 | + this.name = name; |
| 29 | + this.author = author; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @return the id |
| 34 | + */ |
| 35 | + public Long getId() { |
| 36 | + return id; |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @param id |
| 41 | + * the id to set |
| 42 | + */ |
| 43 | + public void setId(Long id) { |
| 44 | + this.id = id; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @return the name |
| 49 | + */ |
| 50 | + public String getName() { |
| 51 | + return name; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @param name |
| 56 | + * the name to set |
| 57 | + */ |
| 58 | + public void setName(String name) { |
| 59 | + this.name = name; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @return the author |
| 64 | + */ |
| 65 | + public String getAuthor() { |
| 66 | + return author; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @param author |
| 71 | + * the author to set |
| 72 | + */ |
| 73 | + public void setAuthor(String author) { |
| 74 | + this.author = author; |
| 75 | + } |
73 | 76 |
|
| 77 | + /* |
| 78 | + * (non-Javadoc) |
| 79 | + * |
| 80 | + * @see java.lang.Object#toString() |
| 81 | + */ |
| 82 | + @Override |
| 83 | + public String toString() { |
| 84 | + return "Book [id=" + id + ", name=" + name + ", author=" + author + "]"; |
| 85 | + } |
74 | 86 |
|
75 | 87 | } |
0 commit comments