Class ImmutableSortedSetFauxverideShim<E>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>
    Direct Known Subclasses:
    ImmutableSortedSet

    abstract class ImmutableSortedSetFauxverideShim<E>
    extends ImmutableSet<E>
    "Overrides" the ImmutableSet static methods that lack ImmutableSortedSet equivalents with deprecated, exception-throwing versions. This prevents accidents like the following:
    
     List<Object> objects = ...;
     // Sort them:
     Set<Object> sorted = ImmutableSortedSet.copyOf(objects);
     // BAD CODE! The returned set is actually an unsorted ImmutableSet!
     

    While we could put the overrides in ImmutableSortedSet itself, it seems clearer to separate these "do not call" methods from those intended for normal use.