This is an interesting point that seems to illustrate a small hole in the collections API.
The fact is that Collections.singleton() defined to return Set , not SortedSet , and in fact, the implementation does not support this interface. I don't think it would be useful for Collections.singleton() to change their behavior and return an instance of SortedSet . This will encourage implementations to perform instanceof checks and downing. (And similarly for the corresponding Map methods and interfaces.)
This is a small consolation for this emptyNavigableSet use, but new methods for Collections.emptyNavigableMap and emptyNavigableSet have been introduced in Java SE 8. This is useful for use cases where you need an empty navigation collection, but if you really want a navigation system with a single element or display, you're out of luck. There is a request for improvement of JDK-6201174, which covers a similar area; I updated and focused it on providing an API for a singleton navigation set and map.
But wait! As you pointed out , there are several additional states that are used together with sorted / moved collections, which is a comparator. (Or in the absence of a comparator, implicitly one that provides natural ordering.) Any new singleton APIs can also provide this. And this indicates the fact that the above empty * methods do not talk about the Comparator. This seems like another mistake: JDK-8181754 .
Unfortunately, I donโt have a really good workaround for you, except to buckle up and implement a singleton, possibly immutable SortedSet or NavigableSet. You can start with Collections.UnmodifiableNavigableSet . It helps a little, but not much. In fact, an empty navigation set is one of them wrapped around an empty TreeSet ! This is completely useless since you want to avoid TreeSet instances.
I would probably start with AbstractSet and then add a minimal set of methods from SortedSet. There are far fewer methods than NavigableSet, so if you donโt need all of its twists, it would be easier to stick with SortedSet.
source share