JDK-6907251 : (coll) Add wrapper methods to Collections for NavigableSet and NavigableMap
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 7
  • Priority: P5
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_xp,windows_7
  • CPU: x86
  • Submitted: 2009-12-04
  • Updated: 2017-05-16
  • Resolved: 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 Availability 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.