Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.optimumtm.domain.domain.model;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
- import java.util.Collection;
- import java.util.Objects;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.FetchType;
- import javax.persistence.JoinColumn;
- import javax.persistence.ManyToOne;
- import javax.persistence.Table;
- import javax.persistence.Transient;
- import javax.validation.constraints.Email;
- import javax.validation.constraints.NotBlank;
- import javax.validation.constraints.Size;
- import org.hibernate.validator.constraints.br.CPF;
- import org.springframework.security.core.GrantedAuthority;
- /**
- *
- * @author denis.baroni
- */
- @Entity
- @Table(name = "user")
- @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
- public class User extends AbstractModel {
- private static final long serialVersionUID = 1L;
- @Size(max = 100, min = 6)
- @NotBlank
- @Column(name = "username", unique = true)
- private String username;
- @Size(max = 100, min = 6)
- @NotBlank
- @Column(name = "password")
- private String password;
- @Column(name = "active")
- private Boolean active = false;
- @Column(name = "reset_password")
- private Boolean resetPassword = false;
- @Column(name = "administrator")
- @JsonIgnore
- private Boolean administrator = false;
- @NotBlank
- @Size(max = 100)
- @Column(name = "name")
- private String name;
- @Size(max = 200)
- @Column(name = "address")
- private String address;
- @Size(max = 100)
- @Column(name = "district")
- private String district;
- @Column(name = "locality_id")
- private Long localityId;
- @Size(max = 20)
- @Column(name = "phone_number")
- private String phoneNumber;
- @NotBlank
- @Size(max = 100)
- @Column(name = "email", unique = true)
- @Email
- private String email;
- @CPF
- @Size(max = 11, min = 11)
- @Column(name = "cpf")
- private String cpf;
- @Size(max = 15)
- @Column(name = "rg")
- private String rg;
- @ManyToOne(fetch = FetchType.EAGER, optional = false)
- @JoinColumn(name = "authority_id")
- private Authority authority;
- @Transient
- private Collection<? extends GrantedAuthority> authorities;
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public Collection<? extends GrantedAuthority> getAuthorities() {
- return authorities;
- }
- public Boolean getActive() {
- return active;
- }
- public void setActive(Boolean active) {
- this.active = active;
- }
- public void setResetPassword(Boolean resetPassword) {
- this.resetPassword = resetPassword;
- }
- public Boolean getResetPassword() {
- return resetPassword;
- }
- public Boolean getAdministrator() {
- return administrator;
- }
- public void setAdministrator(Boolean administrator) {
- this.administrator = administrator;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getAddress() {
- return address;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- public String getDistrict() {
- return district;
- }
- public void setDistrict(String district) {
- this.district = district;
- }
- public Long getLocalityId() {
- return localityId;
- }
- public void setLocalityId(Long localityId) {
- this.localityId = localityId;
- }
- public String getPhoneNumber() {
- return phoneNumber;
- }
- public void setPhoneNumber(String phoneNumber) {
- this.phoneNumber = phoneNumber;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getCpf() {
- return cpf;
- }
- public void setCpf(String cpf) {
- this.cpf = cpf;
- }
- public String getRg() {
- return rg;
- }
- public void setRg(String rg) {
- this.rg = rg;
- }
- public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
- this.authorities = authorities;
- }
- public Authority getAuthority() {
- return authority;
- }
- public void setAuthority(Authority authority) {
- this.authority = authority;
- }
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 19 * hash + Objects.hashCode(this.username);
- hash = 19 * hash + Objects.hashCode(this.password);
- hash = 19 * hash + Objects.hashCode(this.active);
- hash = 19 * hash + Objects.hashCode(this.resetPassword);
- hash = 19 * hash + Objects.hashCode(this.administrator);
- hash = 19 * hash + Objects.hashCode(this.name);
- hash = 19 * hash + Objects.hashCode(this.address);
- hash = 19 * hash + Objects.hashCode(this.district);
- hash = 19 * hash + Objects.hashCode(this.localityId);
- hash = 19 * hash + Objects.hashCode(this.phoneNumber);
- hash = 19 * hash + Objects.hashCode(this.email);
- hash = 19 * hash + Objects.hashCode(this.cpf);
- hash = 19 * hash + Objects.hashCode(this.rg);
- hash = 19 * hash + Objects.hashCode(this.authority);
- hash = 19 * hash + Objects.hashCode(this.authorities);
- return hash;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final User other = (User) obj;
- if (!Objects.equals(this.username, other.username)) {
- return false;
- }
- if (!Objects.equals(this.password, other.password)) {
- return false;
- }
- if (!Objects.equals(this.name, other.name)) {
- return false;
- }
- if (!Objects.equals(this.address, other.address)) {
- return false;
- }
- if (!Objects.equals(this.district, other.district)) {
- return false;
- }
- if (!Objects.equals(this.phoneNumber, other.phoneNumber)) {
- return false;
- }
- if (!Objects.equals(this.email, other.email)) {
- return false;
- }
- if (!Objects.equals(this.cpf, other.cpf)) {
- return false;
- }
- if (!Objects.equals(this.rg, other.rg)) {
- return false;
- }
- if (!Objects.equals(this.active, other.active)) {
- return false;
- }
- if (!Objects.equals(this.resetPassword, other.resetPassword)) {
- return false;
- }
- if (!Objects.equals(this.administrator, other.administrator)) {
- return false;
- }
- if (!Objects.equals(this.localityId, other.localityId)) {
- return false;
- }
- if (!Objects.equals(this.authority, other.authority)) {
- return false;
- }
- return Objects.equals(this.authorities, other.authorities);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement