/java/

Equals, hashCode and toString Builder

2013-08-24 15:04:21

I hate long ugly methods. That is why I must do something with equals, hashCode and toString, because they are super ugly.

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

<dependency>
<groupid>org.apache.commons</groupid>
<artifactid>commons-lang3</artifactid>
<version>3.1</version>
</dependency>