/src/main/java/com/cactus/domain/User.java

https://gitlab.com/nicolas1729/cactus · Java · 204 lines · 154 code · 47 blank · 3 comment · 7 complexity · 05cb7bd3654217d558cc84fe5b84da16 MD5 · raw file

  1. package com.cactus.domain;
  2. import com.fasterxml.jackson.annotation.JsonIgnore;
  3. import org.hibernate.validator.constraints.Email;
  4. import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
  5. import com.fasterxml.jackson.databind.annotation.JsonSerialize;
  6. import org.springframework.data.annotation.Id;
  7. import org.springframework.data.mongodb.core.mapping.Document;
  8. import org.springframework.data.mongodb.core.mapping.Field;
  9. import javax.validation.constraints.NotNull;
  10. import javax.validation.constraints.Pattern;
  11. import javax.validation.constraints.Size;
  12. import java.io.Serializable;
  13. import java.util.HashSet;
  14. import java.util.Set;
  15. import java.time.ZonedDateTime;
  16. /**
  17. * A user.
  18. */
  19. @Document(collection = "jhi_user")
  20. public class User extends AbstractAuditingEntity implements Serializable {
  21. @Id
  22. private String id;
  23. @NotNull
  24. @Pattern(regexp = "^[a-z0-9]*$|(anonymousUser)")
  25. @Size(min = 1, max = 50)
  26. private String login;
  27. @JsonIgnore
  28. @NotNull
  29. @Size(min = 60, max = 60)
  30. private String password;
  31. @Size(max = 50)
  32. @Field("first_name")
  33. private String firstName;
  34. @Size(max = 50)
  35. @Field("last_name")
  36. private String lastName;
  37. @Email
  38. @Size(max = 100)
  39. private String email;
  40. private boolean activated = false;
  41. @Size(min = 2, max = 5)
  42. @Field("lang_key")
  43. private String langKey;
  44. @Size(max = 20)
  45. @Field("activation_key")
  46. @JsonIgnore
  47. private String activationKey;
  48. @Size(max = 20)
  49. @Field("reset_key")
  50. private String resetKey;
  51. @Field("reset_date")
  52. private ZonedDateTime resetDate = null;
  53. @JsonIgnore
  54. private Set<Authority> authorities = new HashSet<>();
  55. public String getId() {
  56. return id;
  57. }
  58. public void setId(String id) {
  59. this.id = id;
  60. }
  61. public String getLogin() {
  62. return login;
  63. }
  64. public void setLogin(String login) {
  65. this.login = login;
  66. }
  67. public String getPassword() {
  68. return password;
  69. }
  70. public void setPassword(String password) {
  71. this.password = password;
  72. }
  73. public String getFirstName() {
  74. return firstName;
  75. }
  76. public void setFirstName(String firstName) {
  77. this.firstName = firstName;
  78. }
  79. public String getLastName() {
  80. return lastName;
  81. }
  82. public void setLastName(String lastName) {
  83. this.lastName = lastName;
  84. }
  85. public String getEmail() {
  86. return email;
  87. }
  88. public void setEmail(String email) {
  89. this.email = email;
  90. }
  91. public boolean getActivated() {
  92. return activated;
  93. }
  94. public void setActivated(boolean activated) {
  95. this.activated = activated;
  96. }
  97. public String getActivationKey() {
  98. return activationKey;
  99. }
  100. public void setActivationKey(String activationKey) {
  101. this.activationKey = activationKey;
  102. }
  103. public String getResetKey() {
  104. return resetKey;
  105. }
  106. public void setResetKey(String resetKey) {
  107. this.resetKey = resetKey;
  108. }
  109. public ZonedDateTime getResetDate() {
  110. return resetDate;
  111. }
  112. public void setResetDate(ZonedDateTime resetDate) {
  113. this.resetDate = resetDate;
  114. }
  115. public String getLangKey() {
  116. return langKey;
  117. }
  118. public void setLangKey(String langKey) {
  119. this.langKey = langKey;
  120. }
  121. public Set<Authority> getAuthorities() {
  122. return authorities;
  123. }
  124. public void setAuthorities(Set<Authority> authorities) {
  125. this.authorities = authorities;
  126. }
  127. @Override
  128. public boolean equals(Object o) {
  129. if (this == o) {
  130. return true;
  131. }
  132. if (o == null || getClass() != o.getClass()) {
  133. return false;
  134. }
  135. User user = (User) o;
  136. if (!login.equals(user.login)) {
  137. return false;
  138. }
  139. return true;
  140. }
  141. @Override
  142. public int hashCode() {
  143. return login.hashCode();
  144. }
  145. @Override
  146. public String toString() {
  147. return "User{" +
  148. "login='" + login + '\'' +
  149. ", firstName='" + firstName + '\'' +
  150. ", lastName='" + lastName + '\'' +
  151. ", email='" + email + '\'' +
  152. ", activated='" + activated + '\'' +
  153. ", langKey='" + langKey + '\'' +
  154. ", activationKey='" + activationKey + '\'' +
  155. "}";
  156. }
  157. }