Use Lombok to declare the JPA required, protected, default, no-arg constructor.
This commit is contained in:
@@ -22,8 +22,10 @@ import javax.persistence.Table;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@@ -42,6 +44,7 @@ import lombok.ToString;
|
||||
@Table(name = "Contacts")
|
||||
@ToString(of = "name")
|
||||
@EqualsAndHashCode(of = "name")
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@RequiredArgsConstructor(staticName = "newContact")
|
||||
@SuppressWarnings("unused")
|
||||
public class Contact {
|
||||
@@ -55,8 +58,6 @@ public class Contact {
|
||||
@Column(name = "phone_number")
|
||||
private String phoneNumber;
|
||||
|
||||
protected Contact() { }
|
||||
|
||||
public Contact withEmailAddress(String emailAddress) {
|
||||
setEmailAddress(emailAddress);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user