content: package com.konsol.beatstream.domain;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import com.konsol.beatstream.config.Constants;
  import jakarta.validation.constraints.Email;
  import jakarta.validation.constraints.NotNull;
  import jakarta.validation.constraints.Pattern;
  import jakarta.validation.constraints.Size;
  import java.io.Serializable;
  import java.time.Instant;
  import java.util.HashSet;
  import java.util.Locale;
  import java.util.Set;
  import org.apache.commons.lang3.StringUtils;
  import org.springframework.data.annotation.Id;
  import org.springframework.data.mongodb.core.index.Indexed;
  import org.springframework.data.mongodb.core.mapping.Field;
  
  /**
   * A user.
   */
  @org.springframework.data.mongodb.core.mapping.Document(collection = "jhi_user")
  public class User extends AbstractAuditingEntity<String> implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      private String id;
  
      @NotNull
      @Pattern(regexp = Constants.LOGIN_REGEX)
      @Size(min = 1, max = 50)
      @Indexed
      private String login;
  
      @JsonIgnore
      @NotNull
      @Size(min = 60, max = 60)
      private String password;
  
      @Size(max = 50)
      @Field("first_name")
      private String firstName;
  
      @Size(max = 50)
      @Field("last_name")
      private String lastName;
  
      @Email
      @Size(min = 5, max = 254)
      @Indexed
      private String email;
  
      private boolean activated = false;
  
      @Size(min = 2, max = 10)
      @Field("lang_key")
      private String langKey;
  
      @Size(max = 256)
      @Field("image_url")
      private String imageUrl;
  
      @Size(max = 20)
      @Field("activation_key")
      @JsonIgnore
      private String activationKey;
  
      @Size(max = 20)
      @Field("reset_key")
      @JsonIgnore
      private String resetKey;
  
      @Field("reset_date")
      private Instant resetDate = null;
  
      @JsonIgnore
      private Set<Authority> authorities = new HashSet<>();
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getLogin() {
          return login;
      }
  
      // Lowercase the login before saving it in database
      public void setLogin(String login) {
          this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getImageUrl() {
          return imageUrl;
      }
  
      public void setImageUrl(String imageUrl) {
          this.imageUrl = imageUrl;
      }
  
      public boolean isActivated() {
          return activated;
      }
  
      public void setActivated(boolean activated) {
          this.activated = activated;
      }
  
      public String getActivationKey() {
          return activationKey;
      }
  
      public void setActivationKey(String activationKey) {
          this.activationKey = activationKey;
      }
  
      public String getResetKey() {
          return resetKey;
      }
  
      public void setResetKey(String resetKey) {
          this.resetKey = resetKey;
      }
  
      public Instant getResetDate() {
          return resetDate;
      }
  
      public void setResetDate(Instant resetDate) {
          this.resetDate = resetDate;
      }
  
      public String getLangKey() {
          return langKey;
      }
  
      public void setLangKey(String langKey) {
          this.langKey = langKey;
      }
  
      public Set<Authority> getAuthorities() {
          return authorities;
      }
  
      public void setAuthorities(Set<Authority> authorities) {
          this.authorities = authorities;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (!(o instanceof User)) {
              return false;
          }
          return id != null && id.equals(((User) o).id);
      }
  
      @Override
      public int hashCode() {
          // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
          return getClass().hashCode();
      }
  
      // prettier-ignore
      @Override
      public String toString() {
          return "User{" +
              "login='" + login + '\'' +
              ", firstName='" + firstName + '\'' +
              ", lastName='" + lastName + '\'' +
              ", email='" + email + '\'' +
              ", imageUrl='" + imageUrl + '\'' +
              ", activated='" + activated + '\'' +
              ", langKey='" + langKey + '\'' +
              ", activationKey='" + activationKey + '\'' +
              "}";
      }
  }
  