86 lines
1.9 KiB
Java

package com.github.prominence.carrepair.model;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Objects;
@MappedSuperclass
abstract public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
@NotNull
@Size(max = 64)
@Column(name = "firstName")
protected String firstName;
@Size(max = 64)
@Column(name = "middleName")
protected String middleName;
@NotNull
@Size(max = 64)
@Column(name = "lastName")
protected String lastName;
public Person(String firstName, String middleName, String lastName) {
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
}
public Person() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Person)) return false;
Person person = (Person) o;
return id == person.id &&
Objects.equals(firstName, person.firstName) &&
Objects.equals(middleName, person.middleName) &&
Objects.equals(lastName, person.lastName);
}
@Override
public int hashCode() {
return Objects.hash(id, firstName, middleName, lastName);
}
}