Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.itexon.cleancode;
- import java.util.Date;
- public class Person {
- private String firstName;
- private String lastName;
- private String nationalIdCardNumber;
- private String nationalIdCardType;
- private Nationality nationality;
- private Date birthDate;
- public Person() {
- super();
- }
- public Person(final String firstName,
- final String lastName,
- final String nationalIdCardNumber,
- final String nationalIdCardType,
- final Nationality nationality,
- final Date birthDate) {
- super();
- this.firstName = firstName;
- this.lastName = lastName;
- this.nationalIdCardNumber = nationalIdCardNumber;
- this.nationalIdCardType = nationalIdCardType;
- this.nationality = nationality;
- this.birthDate = birthDate;
- }
- public String getFirstName() {
- return firstName;
- }
- public void setFirstName(final String firstName) {
- this.firstName = firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public void setLastName(final String lastName) {
- this.lastName = lastName;
- }
- public String getNationalIdCardNumber() {
- return nationalIdCardNumber;
- }
- public void setNationalIdCardNumber(final String nationalIdCardNumber) {
- this.nationalIdCardNumber = nationalIdCardNumber;
- }
- public String getNationalIdCardType() {
- return nationalIdCardType;
- }
- public void setNationalIdCardType(final String nationalIdCardType) {
- this.nationalIdCardType = nationalIdCardType;
- }
- public Nationality getNationality() {
- return nationality;
- }
- public void setNationality(final Nationality nationality) {
- this.nationality = nationality;
- }
- public Date getBirthDate() {
- return birthDate;
- }
- public void setBirthDate(final Date birthDate) {
- this.birthDate = birthDate;
- }
- @Override
- public boolean equals(final Object other) {
- final Person otherPerson = (Person) other;
- return firstName != null && firstName.equals(otherPerson.firstName) || firstName == otherPerson.firstName &&
- lastName != null && lastName.equals(otherPerson.lastName) || lastName == otherPerson.lastName &&
- nationalIdCardNumber != null && nationalIdCardNumber.equals(otherPerson.nationalIdCardNumber) || nationalIdCardNumber == otherPerson.nationalIdCardNumber &&
- nationalIdCardType != null && nationalIdCardType.equals(otherPerson.nationalIdCardType) || nationalIdCardType == otherPerson.nationalIdCardType &&
- nationality != null && nationality.equals(otherPerson.nationality) || nationality == otherPerson.nationality &&
- birthDate != null && birthDate.equals(otherPerson.birthDate) || birthDate == otherPerson.birthDate;
- }
- @Override
- public int hashCode() {
- int hashCode = 0;
- hashCode += firstName == null ? 0 : firstName.hashCode();
- hashCode += lastName == null ? 0 : lastName.hashCode();
- hashCode += nationalIdCardNumber == null ? 0 : nationalIdCardNumber.hashCode();
- hashCode += nationalIdCardType == null ? 0 : nationalIdCardType.hashCode();
- hashCode += nationality == null ? 0 : nationality.hashCode();
- hashCode += birthDate == null ? 0 : birthDate.hashCode();
- return hashCode;
- }
- @Override
- public String toString() {
- return "Person{" +
- "firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", nationalIdCardNumber='" + nationalIdCardNumber + '\'' +
- ", nationalIdCardType='" + nationalIdCardType + '\'' +
- ", nationality=" + nationality +
- ", birthDate=" + birthDate +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement