directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: equals() implementation in ProtectedItem
Date Fri, 21 May 2010 09:46:07 GMT
Felix Knecht wrote:
>>> 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.
> 

I checked X.501 specification [1], Annex E, page 173. It clearly states
that in ProtectedItem all elments (attributeType, allAttributeValues,
attributeValue, selfValue, maxValueCount, restrictedBy) are *sets*.

I'm going to change all Collection types to Sets and activate your tests.

Kind Regards,
Stefan


[1] http://www.itu.int/rec/T-REC-X.501-200508-I

Mime
View raw message