directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Knecht <fel...@apache.org>
Subject Re: equals() implementation in ProtectedItem
Date Fri, 21 May 2010 08:28:11 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>> Are you aware, that this [1] is an equal of collections and will return
>> in most cases "false" as it is a reference comparison [2]?

Thanks to test cases :)
> 
> I checked the history. Previously we didn't use
>   Collections.unmodifiableCollection( attributeTypes )
> And a quick check shows that the callers of the construtor always pass
> an java.util.Set.
> 
> For two Sets the equals method would work correctly, but the creation of
> the unmodifyalbe collection not.
> 
> I think we have two options:
> - use CollectionUtils.isEqualCollection() from commons collections, this
> seems to do the right thing.
> - try to change the parameter type from Collection to Set in the
> constructors and use Collections.unmodifiableSet() instead.
> 
> Thoughts?

It dependes on the content we have in the collections. Set doesn't
allows duplicates wheras with certain collection implementations this is
possible.

>> [1]
>> http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/aci/ProtectedItem.html#245
>> [2]
>> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html#equals%28java.lang.Object%29
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkv2RBsACgkQ2lZVCB08qHEMRwCgqw/vU0yLW9MLaxJu84yseUiO
LtwAn0L5ez3u/jYUA0CIkfsT68qi371a
=hQz9
-----END PGP SIGNATURE-----

Mime
View raw message