JDK-6907251 : (coll) Add wrapper methods to Collections for NavigableSet and NavigableMap
  • Type: Enhancement
  • Status: Resolved
  • Resolution: Duplicate
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P5
  • Affected Version: 7
  • OS: windows_xp,windows_7
  • CPU: x86
  • Submit Date: 2009-12-04
  • Updated Date: 2017-05-16
  • Resolved Date: 2013-07-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
There are no wrapper methods in java.util.Collections for NavigableSet or NavigableMap.  Please consider adding the following:
checkedNavigableSet
checkedNavigableMap
synchronizedNavigableSet
synchronizedNavigableMap
unmodifiableNavigableSet
unmodifiableNavigableMap


JUSTIFICATION :
NavigableSet and NavigableMap provide highly useful enhancements to SortedSet and SortedMap.  Returning unmodifiable forms of them is often a cheap way to provide encapsulation of internal data kept in a NavigableSet or NavigableMap, especially data of immutable objects.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would like the java.util.Collections class to have wrapper methods for NavigableSet and NavigableMap.
ACTUAL -
Currently, there are no wrapper methods for NavigableSet and NavigableMap.

CUSTOMER SUBMITTED WORKAROUND :
1. Use SortedSet and SortedMap, if the reduced functionality is acceptable.
2.Write the wrappers oneself (which isn't as easy as it sounds, since all the returned Map.Entrys, collection views and descending views also need to be checked/unmodifiable).
3. Use defensive copying instead of unmodifiable wrappers;  use manual synchronization instead of synchronized wrappers.