import java.util.Date;
import java.util.Map;
public class Person {
private int id;
private String firstName;
private String lastName;
private Date birthdate;
//Эта штука добавлена @TupleConstructor-ом
public Person(Map parameters){
this.id = (int) parameters.get("id");
this.firstName = (String) parameters.get("firstName");
this.lastName = (String) parameters.get("lastName");
this.birthdate = (Date) parameters.get("birthdate");
}
public Person(int id, String firstName, String lastName, Date birthdate) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.birthdate =birthdate;
}
public Person(int id, String firstName, String lastName) {
this(id, firstName, lastName, null);
}
public Person(int id, String firstName) {
this(id, firstName, null, null);
}
public Person(int id) {
this(id, null, null, null);
}
public Person() {
this(0, null, null, null);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
if (id != person.id) return false;
if (birthdate != null ? !birthdate.equals(person.birthdate) : person.birthdate != null) return false;
if (firstName != null ? !firstName.equals(person.firstName) : person.firstName != null) return false;
if (lastName != null ? !lastName.equals(person.lastName) : person.lastName != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
result = 31 * result + (birthdate != null ? birthdate.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Person{" +
"id=" + id +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", birthdate=" + birthdate +
'}';
}
public int getId() {
return this.id;
}
public void setId(int paramInt) {
this.id = paramInt;
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String paramString) {
this.firstName = paramString;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String paramString) {
this.lastName = paramString;
}
public Date getBirthdate() {
return this.birthdate;
}
public void setBirthdate(Date paramDate) {
this.birthdate = paramDate;
}
}