package de.terrestris.shogun2.model;

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

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * @author Nils Bühner
 *
 */
@Entity
@Table
public class Role extends PersistentObject {

	private static final long serialVersionUID = 1L;

	@Column
	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())
				.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()).isEquals();
	}

	/**
	 *
	 */
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
	}
}

@@ -501,32 +501,61 @@
  = 1L;%0A%0A%09@Column
+(unique=true, nullable=false)
 %0A%09private String
@@ -1572,24 +1572,54 @@
 (getName())%0A
+%09%09%09%09.append(getDescription())%0A
 %09%09%09%09.toHashC
@@ -2123,16 +2123,70 @@
 tName())
+%0A%09%09%09%09.append(getDescription(), other.getDescription())
 .isEqual

Make role name unique und not nullable