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 18791] New: - BeanComparator should handle null property values (?)
Date Tue, 08 Apr 2003 03:01:54 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18791>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18791

BeanComparator should handle null property values (?)

           Summary: BeanComparator should handle null property values (?)
           Product: Commons
           Version: Nightly Builds
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Bean Utilities
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: tobrien@discursive.com


Assume a "Person" with 3 string properties age, name, hairColor.  We've got 
three people, Bob, Jane, and John - John happens to be bald, and his hairColor 
property is "null".  Trying to sort a collection of Person beans by hairColor 
with a null entry throws a ClassCastException from ComparableComparator. 

" java.lang.ClassCastException: There were nulls in the arguments for this 
method: compare(hawkeye, null)' " 

One should be able to sort a collection of beans on a property which contains 
null values.  The question that remains is whether the comparing with a null 
should return a 1 or a -1 (do you want your nulls in the beginning or at the 
end?).  I'd assume at the end as the default behaviour - maybe add a property 
to allow people to customize this.

---------------------------------------------------------------------
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