commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30855] New: - additional constructor for EqualsBuilder
Date Thu, 26 Aug 2004 02:36:24 GMT
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


Mime
View raw message