Advertisement
Guest User

Código ceremonioso

a guest
Jul 16th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.itexon.cleancode;
  2.  
  3. import java.util.Date;
  4.  
  5. public class Person {
  6.  
  7.     private String firstName;
  8.  
  9.     private String lastName;
  10.  
  11.     private String nationalIdCardNumber;
  12.  
  13.     private String nationalIdCardType;
  14.  
  15.     private Nationality nationality;
  16.  
  17.     private Date birthDate;
  18.  
  19.     public Person() {
  20.         super();
  21.     }
  22.  
  23.     public Person(final String firstName,
  24.                   final String lastName,
  25.                   final String nationalIdCardNumber,
  26.                   final String nationalIdCardType,
  27.                   final Nationality nationality,
  28.                   final Date birthDate) {
  29.         super();
  30.         this.firstName = firstName;
  31.         this.lastName = lastName;
  32.         this.nationalIdCardNumber = nationalIdCardNumber;
  33.         this.nationalIdCardType = nationalIdCardType;
  34.         this.nationality = nationality;
  35.         this.birthDate = birthDate;
  36.     }
  37.  
  38.     public String getFirstName() {
  39.         return firstName;
  40.     }
  41.  
  42.     public void setFirstName(final String firstName) {
  43.         this.firstName = firstName;
  44.     }
  45.  
  46.     public String getLastName() {
  47.         return lastName;
  48.     }
  49.  
  50.     public void setLastName(final String lastName) {
  51.         this.lastName = lastName;
  52.     }
  53.  
  54.     public String getNationalIdCardNumber() {
  55.         return nationalIdCardNumber;
  56.     }
  57.  
  58.     public void setNationalIdCardNumber(final String nationalIdCardNumber) {
  59.         this.nationalIdCardNumber = nationalIdCardNumber;
  60.     }
  61.  
  62.     public String getNationalIdCardType() {
  63.         return nationalIdCardType;
  64.     }
  65.  
  66.     public void setNationalIdCardType(final String nationalIdCardType) {
  67.         this.nationalIdCardType = nationalIdCardType;
  68.     }
  69.  
  70.     public Nationality getNationality() {
  71.         return nationality;
  72.     }
  73.  
  74.     public void setNationality(final Nationality nationality) {
  75.         this.nationality = nationality;
  76.     }
  77.  
  78.     public Date getBirthDate() {
  79.         return birthDate;
  80.     }
  81.  
  82.     public void setBirthDate(final Date birthDate) {
  83.         this.birthDate = birthDate;
  84.     }
  85.  
  86.     @Override
  87.     public boolean equals(final Object other) {
  88.         final Person otherPerson = (Person) other;
  89.         return firstName != null && firstName.equals(otherPerson.firstName) || firstName == otherPerson.firstName &&
  90.                 lastName != null && lastName.equals(otherPerson.lastName) || lastName == otherPerson.lastName &&
  91.                 nationalIdCardNumber != null && nationalIdCardNumber.equals(otherPerson.nationalIdCardNumber) || nationalIdCardNumber == otherPerson.nationalIdCardNumber &&
  92.                 nationalIdCardType != null && nationalIdCardType.equals(otherPerson.nationalIdCardType) || nationalIdCardType == otherPerson.nationalIdCardType &&
  93.                 nationality != null && nationality.equals(otherPerson.nationality) || nationality == otherPerson.nationality &&
  94.                 birthDate != null && birthDate.equals(otherPerson.birthDate) || birthDate == otherPerson.birthDate;
  95.     }
  96.  
  97.     @Override
  98.     public int hashCode() {
  99.         int hashCode = 0;
  100.         hashCode += firstName == null ? 0 : firstName.hashCode();
  101.         hashCode += lastName == null ? 0 : lastName.hashCode();
  102.         hashCode += nationalIdCardNumber == null ? 0 : nationalIdCardNumber.hashCode();
  103.         hashCode += nationalIdCardType == null ? 0 : nationalIdCardType.hashCode();
  104.         hashCode += nationality == null ? 0 : nationality.hashCode();
  105.         hashCode += birthDate == null ? 0 : birthDate.hashCode();
  106.  
  107.         return hashCode;
  108.     }
  109.  
  110.     @Override
  111.     public String toString() {
  112.         return "Person{" +
  113.                 "firstName='" + firstName + '\'' +
  114.                 ", lastName='" + lastName + '\'' +
  115.                 ", nationalIdCardNumber='" + nationalIdCardNumber + '\'' +
  116.                 ", nationalIdCardType='" + nationalIdCardType + '\'' +
  117.                 ", nationality=" + nationality +
  118.                 ", birthDate=" + birthDate +
  119.                 '}';
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement