Do we need HyperJAXB generated hashCode & equals methods?

Posted by Marcus on Stack Overflow See other posts from Stack Overflow or by Marcus
Published on 2010-04-13T11:01:46Z Indexed on 2010/04/13 11:02 UTC
Read the original article Hit count: 336

Filed under:
|

We've generated some (well a lot) of classes using HyperJAXB. All of the classes implement Equals and HashCode and have the implementation style below. Appears this code is never executed.. is there any particular reason we need this code? I'm looking to simplify the classes if we can.

   public boolean equals(Object object) {
        if (!(object instanceof MyClass)) {
            return false;
        }
        if (this == object) {
            return true;
        }
        final EqualsBuilder equalsBuilder = new JAXBEqualsBuilder();
        equals(object, equalsBuilder);
        return equalsBuilder.isEquals();
    }

    public void hashCode(HashCodeBuilder hashCodeBuilder) {
        hashCodeBuilder.append(this.getValue());
        hashCodeBuilder.append(this.getId());
    }

    public int hashCode() {
        final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder();
        hashCode(hashCodeBuilder);
        return hashCodeBuilder.toHashCode();
    }

© Stack Overflow or respective owner

Related posts about hyperjaxb

Related posts about java