src/main/java/de/uapcore/lightpit/entities/User.java

changeset 37
fecda0f466e6
parent 33
fd8c40ff78c3
child 47
57cfb94ab99f
     1.1 --- a/src/main/java/de/uapcore/lightpit/entities/User.java	Sun May 10 10:11:37 2020 +0200
     1.2 +++ b/src/main/java/de/uapcore/lightpit/entities/User.java	Sun May 10 10:58:31 2020 +0200
     1.3 @@ -28,23 +28,26 @@
     1.4   */
     1.5  package de.uapcore.lightpit.entities;
     1.6  
     1.7 +import java.util.Objects;
     1.8 +
     1.9  public final class User {
    1.10  
    1.11      public static final int ANONYMOUS_USERID = -1;
    1.12  
    1.13 -    private int userID;
    1.14 +    private final int userID;
    1.15      private String username;
    1.16 +    private String mail;
    1.17      private String givenname;
    1.18      private String lastname;
    1.19  
    1.20 +    public User(int userID) {
    1.21 +        this.userID = userID;
    1.22 +    }
    1.23 +
    1.24      public int getUserID() {
    1.25          return userID;
    1.26      }
    1.27  
    1.28 -    public void setUserID(int userID) {
    1.29 -        this.userID = userID;
    1.30 -    }
    1.31 -
    1.32      public String getUsername() {
    1.33          return username;
    1.34      }
    1.35 @@ -53,6 +56,14 @@
    1.36          this.username = username;
    1.37      }
    1.38  
    1.39 +    public String getMail() {
    1.40 +        return mail;
    1.41 +    }
    1.42 +
    1.43 +    public void setMail(String mail) {
    1.44 +        this.mail = mail;
    1.45 +    }
    1.46 +
    1.47      public String getGivenname() {
    1.48          return givenname;
    1.49      }
    1.50 @@ -70,21 +81,15 @@
    1.51      }
    1.52  
    1.53      @Override
    1.54 -    public int hashCode() {
    1.55 -        int hash = 3;
    1.56 -        hash = 41 * hash + this.userID;
    1.57 -        return hash;
    1.58 +    public boolean equals(Object o) {
    1.59 +        if (this == o) return true;
    1.60 +        if (o == null || getClass() != o.getClass()) return false;
    1.61 +        User user = (User) o;
    1.62 +        return userID == user.userID;
    1.63      }
    1.64  
    1.65      @Override
    1.66 -    public boolean equals(Object obj) {
    1.67 -        if (this == obj) {
    1.68 -            return true;
    1.69 -        }
    1.70 -        if (obj == null || getClass() != obj.getClass()) {
    1.71 -            return false;
    1.72 -        } else {
    1.73 -            return this.userID == ((User) obj).userID;
    1.74 -        }
    1.75 +    public int hashCode() {
    1.76 +        return Objects.hash(userID);
    1.77      }
    1.78  }

mercurial