-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
None
Name: rmT116609 Date: 10/31/2003
A DESCRIPTION OF THE REQUEST :
A standard pair class would assist developers who constantly write such helper classes.
JUSTIFICATION :
This class is simple to write and would go a long way towards making code more readable as we would not so many little classes which are all 99% the same. Also, could be the base class for other objects and replace Map.Entry which in my opinion should have been an immutable Pair object which would have simplified writing Map implementations, i.e. having an actual class instead of having to re-implement (which while easy is tiresome).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would like pair classes that are mutable, immutable & thread-safe. I would also like second parameters to be optiunal based on either an inheritance model or something else. I also would like a pair that supports the Comparable interface. Note that equals(), hashCode() and toString() should be overridden and implemented to handle first and second.
ACTUAL -
Pair p = new Pair(new Integer(3), "abcde");
p.getFirst();
p.getSecond();
p.toString();
CUSTOMER SUBMITTED WORKAROUND :
I wrote my own pair class.
Pair - optional second
StrictPair - second required
MutablePair - mutable
ComparablePair - first and second are comparable and non-null
ThreadsafePair - mutable and thread-safe
(Incident Review ID: 218844)
======================================================================
- duplicates
-
JDK-6229146 (coll) Please add java.util.Pair
- Closed