<rdf:RDF
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xml:base='http://wiki.marandcustomsolutions.com/rdf'>
    <s:Snip rdf:about='http://wiki.marandcustomsolutions.com/rdf#Development/Java+%26+J2EE/Java+Core'
         s:cUser='mpecher'
         s:oUser=''
         s:mUser='mpecher'>
        <s:name>Development/Java &amp; J2EE/Java Core</s:name>
        <s:content>1 Override equals() and hashcode()&#xD;&#xA;When ever equals() is overriden, so should hashcode() (see {link: Effective Java |http://wiki.marandcustomsolutions.com/space/Books |none}).&#xD;&#xA;Use the commons lang EqualsBuilder, HashCodeBuilder, ToStringBuilder for constructing these.&#xD;&#xA;&#xD;&#xA;1.1 equals()&#xD;&#xA;The equals method allow direct access to the instance variable of the object being compared to.&#xD;&#xA;Direct access to the properties should be avoided where possible, instead the getter methods used.&#xD;&#xA;This is important, since the object instance obj passed to equals might be a proxy object, not the&#xD;&#xA;actual implementation that holds the persistent state (ie. when used through Hibernate etc).&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;    /**&#xD;&#xA;     * override default equals implementation.&#xD;&#xA;     * &#xD;&#xA;     * @param obj&#xD;&#xA;     *            to compare&#xD;&#xA;     * @return whether the two object are equal.&#xD;&#xA;     */&#xD;&#xA;    public boolean equals(Object obj) {&#xD;&#xA;        //short cut for same reference&#xD;&#xA;        if (this == obj) {&#xD;&#xA;            return true;&#xD;&#xA;        }&#xD;&#xA;&#xD;&#xA;        if (!(obj instanceof Column)) {&#xD;&#xA;            return false;&#xD;&#xA;        }&#xD;&#xA;&#xD;&#xA;        Column o = (Column) obj;&#xD;&#xA;        return new EqualsBuilder()&#xD;&#xA;                .append(refCol, o.getRefCol())&#xD;&#xA;                .append(isVisible, o.isVisible())&#xD;&#xA;                .append(sortDir, o.getSortDir())&#xD;&#xA;                .append(name, o.name) // (1) direct access should be avoided&#xD;&#xA;                .isEquals();&#xD;&#xA;    }&#xD;&#xA;{code}&#xD;&#xA;Here at (1) o.name is permissable, but its convience method should be used ie. o.getName().\\&#xD;&#xA;----&#xD;&#xA;1 Eclipse plugin\\&#xD;&#xA;Plugin allows generation of hashCode(), equals(), toString() and compareTo() using commons lang Builders.\\&#xD;&#xA;http://commonclipse.sourceforge.net/index.html</s:content>
        <s:mTime>2006-08-09 11:29:05.0</s:mTime>
        <s:cTime>2006-05-30 14:46:19.0</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li rdf:resource='http://wiki.marandcustomsolutions.com/rdf#Development/Java &amp; J2EE'/>
                <rdf:li rdf:resource='#snipsnap-index'/>
                <rdf:li rdf:resource='#snipsnap-search'/>
                <rdf:li rdf:resource='#Development'/>
                <rdf:li rdf:resource='http://wiki.marandcustomsolutions.com/rdf#Development/Java &amp; J2EE/Hibernate/Mapping'/>
                <rdf:li rdf:resource='http://wiki.marandcustomsolutions.com/rdf#Development/Java &amp; J2EE/Spring'/>
                <rdf:li rdf:resource='#Books'/>
                <rdf:li rdf:resource='http://wiki.marandcustomsolutions.com/rdf#Development/Java &amp; J2EE/Websphere/WebSEAL'/>
            </rdf:Bag>
        </s:snipLinks>
        <s:attachments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
    </s:Snip>
</rdf:RDF>

