package sample.ui.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.security.core.GrantedAuthority;
@Entity
@Table(name = "authorities")
public class Authority extends BaseEntity implements GrantedAuthority {
private static final long serialVersionUID = 8635976989721024158L;
@Column
@NotEmpty
private String authority;
public Authority() {}
public Authority(String authority) {
this.authority = authority;
}
@Override
public String getAuthority() {
return authority;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((authority == null) ? 0 : authority.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Authority other = (Authority) obj;
if (authority == null) {
if (other.authority != null)
return false;
} else if (!authority.equals(other.authority))
return false;
return true;
}
@Override
public String toString() {
return "Authority [authority=" + authority + "]";
}
}