I have a simple class Role:
@Entity
@Table (name = \"ROLE\")
public class Role implements Serializable {
@Id
@GeneratedValue
private Integer id;
Please find below simple instructions how to create hashCode, equals and toString methods using Apache commons builders.
You may call for .appendSuper(super.hashCode()) in case your class is subclass
@Override public int hashCode() { return new HashCodeBuilder() .append(getName()) .toHashCode(); }
You may call for .appendSuper(super.equals(other)) in case your class is subclass
@Override public boolean equals(final Object other) { if (this == other) return true; if (!(other instanceof TreeNode)) return false; TreeNode castOther = (TreeNode) other; return new EqualsBuilder() .append(getName(), castOther.getName()) .isEquals(); }
You may call for .appendSuper(super.toString()) in case your class is subclass
@Override public String toString() { return new ToStringBuilder(this) .append("Name", getName()) .toString(); }