commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: BeanUtils
Date Fri, 07 Mar 2003 02:58:39 GMT


On Thu, 6 Mar 2003 kpullin@tsys.com wrote:

> Date: Thu, 6 Mar 2003 13:50:58 -0500
> From: kpullin@tsys.com
> Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> To: commons-user@jakarta.apache.org
> Subject: BeanUtils
>
> I'm using the BeanUtils class to compare different properties from 2
> objects.  Let's assume I have the following setup:
>
> Class1{
>       private Name name = null;
>       // list contains Strings
>       private List list = null;
>       private String description = null;
>
>       // corresponding setter and getter methods....
>
> }
>
> If I have 2 instance of Class1 and I want to compare them to see if they
> are equal, does the BeanUtils class provide a way to look into the "Name"
> and "List" object to see if they contain the same values?  I know it works
> well with String objects, but I don't see any way that it can work with
> other objects.
>

BeanUtils doesn't have any specific code for this use case, although a
"compare all the properties that two beans have in common" method would be
nice.

If the instances are of the same class, though, why don't you just
override the equals() method and do the appropriate comparisons there?

Craig

Mime
View raw message