Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.51 KB | None | 0 0
  1. package com.optimumtm.domain.domain.model;
  2.  
  3. import com.fasterxml.jackson.annotation.JsonIgnore;
  4. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5. import java.util.Collection;
  6. import java.util.Objects;
  7. import javax.persistence.Column;
  8. import javax.persistence.Entity;
  9. import javax.persistence.FetchType;
  10. import javax.persistence.JoinColumn;
  11. import javax.persistence.ManyToOne;
  12. import javax.persistence.Table;
  13. import javax.persistence.Transient;
  14. import javax.validation.constraints.Email;
  15. import javax.validation.constraints.NotBlank;
  16. import javax.validation.constraints.Size;
  17. import org.hibernate.validator.constraints.br.CPF;
  18. import org.springframework.security.core.GrantedAuthority;
  19.  
  20. /**
  21.  *
  22.  * @author denis.baroni
  23.  */
  24. @Entity
  25. @Table(name = "user")
  26. @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
  27. public class User extends AbstractModel {
  28.  
  29.     private static final long serialVersionUID = 1L;
  30.  
  31.     @Size(max = 100, min = 6)
  32.     @NotBlank
  33.     @Column(name = "username", unique = true)
  34.     private String username;
  35.  
  36.     @Size(max = 100, min = 6)
  37.     @NotBlank
  38.     @Column(name = "password")
  39.     private String password;
  40.  
  41.     @Column(name = "active")
  42.     private Boolean active = false;
  43.  
  44.     @Column(name = "reset_password")
  45.     private Boolean resetPassword = false;
  46.  
  47.     @Column(name = "administrator")
  48.     @JsonIgnore
  49.     private Boolean administrator = false;
  50.  
  51.     @NotBlank
  52.     @Size(max = 100)
  53.     @Column(name = "name")
  54.     private String name;
  55.  
  56.     @Size(max = 200)
  57.     @Column(name = "address")
  58.     private String address;
  59.  
  60.     @Size(max = 100)
  61.     @Column(name = "district")
  62.     private String district;
  63.  
  64.     @Column(name = "locality_id")
  65.     private Long localityId;
  66.  
  67.     @Size(max = 20)
  68.     @Column(name = "phone_number")
  69.     private String phoneNumber;
  70.  
  71.     @NotBlank
  72.     @Size(max = 100)
  73.     @Column(name = "email", unique = true)
  74.     @Email
  75.     private String email;
  76.  
  77.     @CPF
  78.     @Size(max = 11, min = 11)
  79.     @Column(name = "cpf")
  80.     private String cpf;
  81.  
  82.     @Size(max = 15)
  83.     @Column(name = "rg")
  84.     private String rg;
  85.    
  86.     @ManyToOne(fetch = FetchType.EAGER, optional = false)
  87.     @JoinColumn(name = "authority_id")
  88.     private Authority authority;
  89.  
  90.     @Transient
  91.     private Collection<? extends GrantedAuthority> authorities;
  92.  
  93.     public String getUsername() {
  94.         return username;
  95.     }
  96.  
  97.     public void setUsername(String username) {
  98.         this.username = username;
  99.     }
  100.  
  101.     public String getPassword() {
  102.         return password;
  103.     }
  104.  
  105.     public void setPassword(String password) {
  106.         this.password = password;
  107.     }
  108.  
  109.     public Collection<? extends GrantedAuthority> getAuthorities() {
  110.         return authorities;
  111.     }
  112.  
  113.     public Boolean getActive() {
  114.         return active;
  115.     }
  116.  
  117.     public void setActive(Boolean active) {
  118.         this.active = active;
  119.     }
  120.  
  121.     public void setResetPassword(Boolean resetPassword) {
  122.         this.resetPassword = resetPassword;
  123.     }
  124.  
  125.     public Boolean getResetPassword() {
  126.         return resetPassword;
  127.     }
  128.  
  129.     public Boolean getAdministrator() {
  130.         return administrator;
  131.     }
  132.  
  133.     public void setAdministrator(Boolean administrator) {
  134.         this.administrator = administrator;
  135.     }
  136.  
  137.     public String getName() {
  138.         return name;
  139.     }
  140.  
  141.     public void setName(String name) {
  142.         this.name = name;
  143.     }
  144.  
  145.     public String getAddress() {
  146.         return address;
  147.     }
  148.  
  149.     public void setAddress(String address) {
  150.         this.address = address;
  151.     }
  152.  
  153.     public String getDistrict() {
  154.         return district;
  155.     }
  156.  
  157.     public void setDistrict(String district) {
  158.         this.district = district;
  159.     }
  160.  
  161.     public Long getLocalityId() {
  162.         return localityId;
  163.     }
  164.  
  165.     public void setLocalityId(Long localityId) {
  166.         this.localityId = localityId;
  167.     }
  168.  
  169.     public String getPhoneNumber() {
  170.         return phoneNumber;
  171.     }
  172.  
  173.     public void setPhoneNumber(String phoneNumber) {
  174.         this.phoneNumber = phoneNumber;
  175.     }
  176.  
  177.     public String getEmail() {
  178.         return email;
  179.     }
  180.  
  181.     public void setEmail(String email) {
  182.         this.email = email;
  183.     }
  184.  
  185.     public String getCpf() {
  186.         return cpf;
  187.     }
  188.  
  189.     public void setCpf(String cpf) {
  190.         this.cpf = cpf;
  191.     }
  192.  
  193.     public String getRg() {
  194.         return rg;
  195.     }
  196.  
  197.     public void setRg(String rg) {
  198.         this.rg = rg;
  199.     }
  200.  
  201.     public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
  202.         this.authorities = authorities;
  203.     }
  204.  
  205.     public Authority getAuthority() {
  206.         return authority;
  207.     }
  208.  
  209.     public void setAuthority(Authority authority) {
  210.         this.authority = authority;
  211.     }
  212.  
  213.     @Override
  214.     public int hashCode() {
  215.         int hash = 7;
  216.         hash = 19 * hash + Objects.hashCode(this.username);
  217.         hash = 19 * hash + Objects.hashCode(this.password);
  218.         hash = 19 * hash + Objects.hashCode(this.active);
  219.         hash = 19 * hash + Objects.hashCode(this.resetPassword);
  220.         hash = 19 * hash + Objects.hashCode(this.administrator);
  221.         hash = 19 * hash + Objects.hashCode(this.name);
  222.         hash = 19 * hash + Objects.hashCode(this.address);
  223.         hash = 19 * hash + Objects.hashCode(this.district);
  224.         hash = 19 * hash + Objects.hashCode(this.localityId);
  225.         hash = 19 * hash + Objects.hashCode(this.phoneNumber);
  226.         hash = 19 * hash + Objects.hashCode(this.email);
  227.         hash = 19 * hash + Objects.hashCode(this.cpf);
  228.         hash = 19 * hash + Objects.hashCode(this.rg);
  229.         hash = 19 * hash + Objects.hashCode(this.authority);
  230.         hash = 19 * hash + Objects.hashCode(this.authorities);
  231.         return hash;
  232.     }
  233.  
  234.     @Override
  235.     public boolean equals(Object obj) {
  236.         if (this == obj) {
  237.             return true;
  238.         }
  239.         if (obj == null) {
  240.             return false;
  241.         }
  242.         if (getClass() != obj.getClass()) {
  243.             return false;
  244.         }
  245.         final User other = (User) obj;
  246.         if (!Objects.equals(this.username, other.username)) {
  247.             return false;
  248.         }
  249.         if (!Objects.equals(this.password, other.password)) {
  250.             return false;
  251.         }
  252.         if (!Objects.equals(this.name, other.name)) {
  253.             return false;
  254.         }
  255.         if (!Objects.equals(this.address, other.address)) {
  256.             return false;
  257.         }
  258.         if (!Objects.equals(this.district, other.district)) {
  259.             return false;
  260.         }
  261.         if (!Objects.equals(this.phoneNumber, other.phoneNumber)) {
  262.             return false;
  263.         }
  264.         if (!Objects.equals(this.email, other.email)) {
  265.             return false;
  266.         }
  267.         if (!Objects.equals(this.cpf, other.cpf)) {
  268.             return false;
  269.         }
  270.         if (!Objects.equals(this.rg, other.rg)) {
  271.             return false;
  272.         }
  273.         if (!Objects.equals(this.active, other.active)) {
  274.             return false;
  275.         }
  276.         if (!Objects.equals(this.resetPassword, other.resetPassword)) {
  277.             return false;
  278.         }
  279.         if (!Objects.equals(this.administrator, other.administrator)) {
  280.             return false;
  281.         }
  282.         if (!Objects.equals(this.localityId, other.localityId)) {
  283.             return false;
  284.         }
  285.         if (!Objects.equals(this.authority, other.authority)) {
  286.             return false;
  287.         }
  288.         return Objects.equals(this.authorities, other.authorities);
  289.     }
  290.    
  291.    
  292.    
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement