⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 role.java

📁 基于Maven的质量保证自动化环境配置和演示程序
💻 JAVA
字号:
package com.cib.model;import java.io.Serializable;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.NamedQueries;import javax.persistence.NamedQuery;import javax.persistence.Table;import javax.persistence.Transient;import org.springframework.security.GrantedAuthority;import org.apache.commons.lang.builder.ToStringBuilder;import org.apache.commons.lang.builder.ToStringStyle;/** * This class is used to represent available roles in the database. * * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a> *         Version by Dan Kibler dan@getrolling.com *         Extended to implement Acegi GrantedAuthority interface *         by David Carter david@carter.net */@Entity@Table(name="role")@NamedQueries ({    @NamedQuery(        name = "findRoleByName",        query = "select r from Role r where r.name = :name "        )})public class Role extends BaseObject implements Serializable, GrantedAuthority {    private static final long serialVersionUID = 3690197650654049848L;    private Long id;    private String name;    private String description;    /**     * Default constructor - creates a new instance with no values set.     */    public Role() {    }    /**     * Create a new instance and set the name.     * @param name name of the role.     */    public Role(final String name) {        this.name = name;    }    @Id  @GeneratedValue(strategy=GenerationType.AUTO)    public Long getId() {        return id;    }    /**     * @see org.springframework.security.GrantedAuthority#getAuthority()     * @return the name property (getAuthority required by Acegi's GrantedAuthority interface)     */    @Transient    public String getAuthority() {        return getName();    }    @Column(length=20)    public String getName() {        return this.name;    }    @Column(length=64)    public String getDescription() {        return this.description;    }    public void setId(Long id) {        this.id = id;    }    public void setName(String name) {        this.name = name;    }    public void setDescription(String description) {        this.description = description;    }    /**     * {@inheritDoc}     */    public boolean equals(Object o) {        if (this == o) {            return true;        }        if (!(o instanceof Role)) {            return false;        }        final Role role = (Role) o;        return !(name != null ? !name.equals(role.name) : role.name != null);    }    /**     * {@inheritDoc}     */    public int hashCode() {        return (name != null ? name.hashCode() : 0);    }    /**     * {@inheritDoc}     */    public String toString() {        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)                .append(this.name)                .toString();    }    public int compareTo(Object o) {        return (equals(o) ? 0 : -1);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -