diff --git a/basics/README.adoc b/basics/README.adoc index ad02f3a..6c76223 100644 --- a/basics/README.adoc +++ b/basics/README.adoc @@ -14,7 +14,7 @@ The cornerstone of any example is the domain object: ---- @Data @Entity -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) class Employee implements Identifiable { @@ -36,7 +36,7 @@ This domain object includes: * `@Data` - Lombok annotation to define a mutable value object * `@Entity` - JPA annotation to make the object storagable in a classic SQL engine (H2 in this example) -* `@NoArgsConstructor` - Lombok annotation to create an empty constructor call to appease Jackson. +* `@NoArgsConstructor(PRIVATE)` - Lombok annotation to create an empty constructor call to appease Jackson, but which is private and not usable to our app's code. * `@AllArgsConstructor` - Lombok annotation to create an all-arg constructor for certain test scenarios * `@JsonIgnoreProperties(ignoreUnknown=true)` - Jackson annotation to ignore unknown attributes when deserializing JSON. diff --git a/basics/src/main/java/org/springframework/hateoas/examples/Employee.java b/basics/src/main/java/org/springframework/hateoas/examples/Employee.java index 20fbf4a..82d5bfd 100644 --- a/basics/src/main/java/org/springframework/hateoas/examples/Employee.java +++ b/basics/src/main/java/org/springframework/hateoas/examples/Employee.java @@ -15,14 +15,15 @@ */ package org.springframework.hateoas.examples; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + import org.springframework.hateoas.Identifiable; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -45,7 +46,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; */ @Data @Entity -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) class Employee implements Identifiable {