All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.terrestris.shoguncore.model.Role Maven / Gradle / Ivy

There is a newer version: 5.3.13
Show newest version
package de.terrestris.shoguncore.model;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @author Nils Bühner
 */
@Entity
@Table
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Role extends PersistentObject {

    private static final long serialVersionUID = 1L;

    @Column(unique = true, nullable = false)
    private String name;

    @Column
    private String description;

    /**
     * Default Constructor
     */
    public Role() {
    }

    /**
     * Constructor
     */
    public Role(String name) {
        this.name = name;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @see java.lang.Object#hashCode()
     * 

* According to * http://stackoverflow.com/questions/27581/overriding-equals * -and-hashcode-in-java it is recommended only to use getter-methods * when using ORM like Hibernate */ @Override public int hashCode() { // two randomly chosen prime numbers return new HashCodeBuilder(13, 53). appendSuper(super.hashCode()). append(getName()). append(getDescription()). toHashCode(); } /** * @see java.lang.Object#equals(java.lang.Object) *

* According to * http://stackoverflow.com/questions/27581/overriding-equals * -and-hashcode-in-java it is recommended only to use getter-methods * when using ORM like Hibernate */ @Override public boolean equals(Object obj) { if (!(obj instanceof Role)) { return false; } Role other = (Role) obj; return new EqualsBuilder(). appendSuper(super.equals(other)). append(getName(), other.getName()). append(getDescription(), other.getDescription()). isEquals(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy