You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/08/26 04:36:24 UTC

DO NOT REPLY [Bug 30855] New: - additional constructor for EqualsBuilder

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30855>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30855

additional constructor for EqualsBuilder

           Summary: additional constructor for EqualsBuilder
           Product: Commons
           Version: 2.0 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Lang
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: ari1meyer@yahoo.com


Hi,

I think it would be helpful to provide another constructor (and corresponding 
boolean member for initial append() checks) for EqualsBuilder as follows:

/*
 * New flag to indicate no need to proceed further
 * An initial check at the beginning of the append() methods could force an 
immediate return
 */ 
protected boolean isDone = false;

...
...

public EqualsBuilder(Object thisObject, Object comparisonObject)
{
	this();
	
	if (comparisonObject == thisObject)
	{
		isDone = true;
	}
	else if ((comparisonObject == null) ||
		(comparisonObject.getClass() != thisObject.getClass())
	{
		isEquals = false;
	}
}

This would mitigate the need to do subsequent field-by-field checking.  Note 
that this also eliminates the "instanceof" symmetric problem described in the 
JavaWorld article by Alex Blewitt:

http://www.javaworld.com/javaworld/jw-06-2004/jw-0614-equals_p.html

Also, based on this article, I would recommend fixing the JavaDoc example to 
NOT use instanceof.

Finally, can they change the member "isEquals" from private to protected?  At 
present, I cannot subclass EqualsBuilder and use this member.

Thank you,
Ari

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org