Advertisement
Slapy

equals&hashCode

Oct 19th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.10 KB | None | 0 0
  1.     @Override
  2.     public boolean equals(Object o) {
  3.         if (this == o) return true;
  4.         if (o == null || getClass() != o.getClass()) return false;
  5.  
  6.         ConnectionTO that = (ConnectionTO) o;
  7.  
  8.         if (isEventsTab() != that.isEventsTab()) return false;
  9.         if (!getUserId().equals(that.getUserId())) return false;
  10.         return getSessionId().equals(that.getSessionId());
  11.  
  12.     }
  13.  
  14.     @Override
  15.     public int hashCode() {
  16.         int result = getUserId().hashCode();
  17.         result = 31 * result + getSessionId().hashCode();
  18.         result = 31 * result + (isEventsTab() ? 1 : 0);
  19.         return result;
  20.     }
  21.  
  22.  
  23.  
  24.     @Override
  25.     public boolean equals(Object o) {
  26.         if (this == o) return true;
  27.  
  28.         if (o == null || getClass() != o.getClass()) return false;
  29.  
  30.         ConnectionTO that = (ConnectionTO) o;
  31.  
  32.         return new EqualsBuilder()
  33.                 .append(isEventsTab(), that.isEventsTab())
  34.                 .append(getUserId(), that.getUserId())
  35.                 .append(getSessionId(), that.getSessionId())
  36.                 .isEquals();
  37.     }
  38.  
  39.     @Override
  40.     public int hashCode() {
  41.         return new HashCodeBuilder(17, 37)
  42.                 .append(getUserId())
  43.                 .append(getSessionId())
  44.                 .append(isEventsTab())
  45.                 .toHashCode();
  46.     }    
  47.  
  48.  
  49.  
  50.  
  51.     @Override
  52.     public boolean equals(Object o) {
  53.         if (this == o) return true;
  54.  
  55.         if (o == null || getClass() != o.getClass()) return false;
  56.  
  57.         ConnectionTO that = (ConnectionTO) o;
  58.  
  59.         return new EqualsBuilder()
  60.                 .append(isEventsTab(), that.isEventsTab())
  61.                 .append(getUserId(), that.getUserId())
  62.                 .append(getSessionId(), that.getSessionId())
  63.                 .isEquals();
  64.     }
  65.  
  66.     @Override
  67.     public int hashCode() {
  68.         return new HashCodeBuilder(17, 37)
  69.                 .append(getUserId())
  70.                 .append(getSessionId())
  71.                 .append(isEventsTab())
  72.                 .toHashCode();
  73.     }    
  74.  
  75.  
  76.  
  77.  
  78.     @Override
  79.     public boolean equals(Object o) {
  80.         if (this == o) return true;
  81.         if (o == null || getClass() != o.getClass()) return false;
  82.         ConnectionTO that = (ConnectionTO) o;
  83.         return isEventsTab() == that.isEventsTab() &&
  84.                 Objects.equal(getUserId(), that.getUserId()) &&
  85.                 Objects.equal(getSessionId(), that.getSessionId());
  86.     }
  87.  
  88.     @Override
  89.     public int hashCode() {
  90.         return Objects.hashCode(getUserId(), getSessionId(), isEventsTab());
  91.     }    
  92.  
  93.  
  94.  
  95.  
  96.  
  97.     @Override
  98.     public boolean equals(Object o) {
  99.         if (this == o) return true;
  100.         if (o == null || getClass() != o.getClass()) return false;
  101.         ConnectionTO that = (ConnectionTO) o;
  102.         return isEventsTab() == that.isEventsTab() &&
  103.                 Objects.equals(getUserId(), that.getUserId()) &&
  104.                 Objects.equals(getSessionId(), that.getSessionId());
  105.     }
  106.  
  107.     @Override
  108.     public int hashCode() {
  109.         return Objects.hash(getUserId(), getSessionId(), isEventsTab());
  110.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement