/*
* The MIT License
*
* Copyright 2012 jdmr.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package mx.edu.um.mateo.general.model;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.IndexColumn;
import org.springframework.security.core.GrantedAuthority;
/**
*
* @author jdmr
*/
@Entity
@Table(name = "roles")
@Cacheable
public class Rol implements Serializable, GrantedAuthority {
/**
*
*/
private static final long serialVersionUID = -6611766368311569317L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Version
private Integer version;
@NotNull
@Column(unique = true, nullable = false, length = 128)
@IndexColumn(name = "rol_authority_idx")
private String authority;
private Integer prioridad;
public Rol() {
}
public Rol(String authority) {
this.authority = authority;
}
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Long id) {
this.id = id;
}
/**
* @return the version
*/
public Integer getVersion() {
return version;
}
/**
* @param version the version to set
*/
public void setVersion(Integer version) {
this.version = version;
}
/**
* @return the authority
*/
@Override
public String getAuthority() {
return authority;
}
/**
* @param authority the authority to set
*/
public void setAuthority(String authority) {
this.authority = authority;
}
/**
* @return the prioridad
*/
public Integer getPrioridad() {
return prioridad;
}
/**
* @param prioridad the prioridad to set
*/
public void setPrioridad(Integer prioridad) {
this.prioridad = prioridad;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Rol other = (Rol) obj;
if (!Objects.equals(this.authority, other.authority)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 11 * hash + Objects.hashCode(this.id);
hash = 11 * hash + Objects.hashCode(this.version);
hash = 11 * hash + Objects.hashCode(this.authority);
return hash;
}
@Override
public String toString() {
return "Rol{" + "authority=" + authority + '}';
}
}