Open Source Support Tools
 
Search Item
 
Summary
  Reported Issue
Title: [COLLECTIONS-242] Add Equator interface for more powerful collections
Project: collections
Item Last Modified: Wed, 25 Jun 2008 16:19:31 -0700 (PDT)
Tags:  
 
 
Bug add added boolean collections comparable comparator compare config? created fix functors href implement interface java kestle made maps objects propose someobject src stephen svn this ticket unresolved values
Details
[COLLECTIONS-242] Add Equator interface for more powerful collections
Reporter:   Stephen Kestle
Created:   Fri, 9 Mar 2007 02:14:20 -0800 (PST)
Updated:   Wed, 25 Jun 2008 16:19:31 -0700 (PDT)
Key:   COLLECTIONS-242
Versions:   Not provided
Environment:  
Priority:   3
Status:   Reopened
Resolution:   Unresolved
Original Link:   http://issues.apache.org/jira/browse/COLLECTIONS-242
Summary:   Add Equator interface for more powerful collections
Description:
Java has Comparable and Comparator to compare objects, and objects have an equals() method. But there is no interface for when an object has multiple ways of being equal.

<p>e.g.: an database object that has a name, code and a value. Equality could be based on:</p>

<ul>
<li>database id</li>
<li>code</li>
<li>name and code</li>
<li>case-insensitive name</li>
</ul>


<p>When extended to collections, this allows us to search for specific
values (with an EqualsPredicate that takes an Equator), and implement
Maps and Sets that use specific equators to determine uniqueness.</p>

<p>I propose that it has two methods:
boolean equate();
int hash();</p>

<p>I shall upload some files when I next get some time.</p>

<p>NB: This ticket is a summary of the email conversation begun on 5 Jan 2007: "equator interface" (<span class="nobr"><a href="http://archives.devshed.com/forums/java-118/equator-interface-2126195.html">http://archives.devshed.com/forums/java-118/equator-interface-2126195.html<sup><img class="rendericon" src="https://issues.apache.org/jira/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>). Stephen C made reference there to creating a FlexiMap, but in my mind, that's additional to this issue (this interface still needs to be created to be able to stand alone).</p>
Comments:
scolebourne Fri, 9 Mar 2007 15:23:06 -0800 (PST)
I think such an interface is a useful extension to the collections framework.
shammah Wed, 2 Apr 2008 00:58:01 -0700 (PDT)
Added Equator interface into functors package
rahul Wed, 2 Apr 2008 12:39:09 -0700 (PDT)
Could you please fix the svn props for files added and make required changes to your svn client's config? See:

http://markmail.org/message/m65kwvj2mrr6zszf

shammah Wed, 25 Jun 2008 16:19:31 -0700 (PDT)
Since I keep referring to this ticket from various places...

Equators are also ensure that you are equating the same types - just found some code that was SomeObject.equals(String) (using a legacy constant instead of a SomeObject one).