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

    @GwtIncompatible
    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.

    • Constructor Detail

      • ImmutableSortedSetFauxverideShim

        ImmutableSortedSetFauxverideShim()
    • Method Detail

      • of

        @Deprecated
        public static <E> ImmutableSortedSet<E> of​(E element)
        Deprecated.
        Pass a parameter of type Comparable to use ImmutableSortedSet.of(Comparable).
        Not supported. You are attempting to create a set that may contain a non-Comparable element. Proper calls will resolve to the version in ImmutableSortedSet, not this dummy version.
        Throws:
        java.lang.UnsupportedOperationException - always
      • of

        @Deprecated
        public static <E> ImmutableSortedSet<E> of​(E e1,
                                                   E e2)
        Deprecated.
        Pass the parameters of type Comparable to use ImmutableSortedSet.of(Comparable, Comparable).
        Not supported. You are attempting to create a set that may contain a non-Comparable element. Proper calls will resolve to the version in ImmutableSortedSet, not this dummy version.
        Throws:
        java.lang.UnsupportedOperationException - always
      • of

        @Deprecated
        public static <E> ImmutableSortedSet<E> of​(E e1,
                                                   E e2,
                                                   E e3)
        Deprecated.
        Pass the parameters of type Comparable to use ImmutableSortedSet.of(Comparable, Comparable, Comparable).
        Not supported. You are attempting to create a set that may contain a non-Comparable element. Proper calls will resolve to the version in ImmutableSortedSet, not this dummy version.
        Throws:
        java.lang.UnsupportedOperationException - always
      • of

        @Deprecated
        public static <E> ImmutableSortedSet<E> of​(E e1,
                                                   E e2,
                                                   E e3,
                                                   E e4)
        Deprecated.
        Pass the parameters of type Comparable to use ImmutableSortedSet.of(Comparable, Comparable, Comparable, Comparable).
        Not supported. You are attempting to create a set that may contain a non-Comparable element. Proper calls will resolve to the version in ImmutableSortedSet, not this dummy version.
        Throws:
        java.lang.UnsupportedOperationException - always
      • copyOf

        @Deprecated
        public static <E> ImmutableSortedSet<E> copyOf​(E[] elements)
        Deprecated.
        Pass parameters of type Comparable to use ImmutableSortedSet.copyOf(Comparable[]).
        Not supported. You are attempting to create a set that may contain non-Comparable elements. Proper calls will resolve to the version in ImmutableSortedSet, not this dummy version.
        Throws:
        java.lang.UnsupportedOperationException - always