1090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/* 21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2009 The Guava Authors 3090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 4090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Licensed under the Apache License, Version 2.0 (the "License"); 5090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * you may not use this file except in compliance with the License. 6090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * You may obtain a copy of the License at 7090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 8090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 9090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 10090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Unless required by applicable law or agreed to in writing, software 11090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 12090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * See the License for the specific language governing permissions and 14090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * limitations under the License. 15090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 16090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 17090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpackage com.google.common.collect; 18090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 19090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport com.google.common.annotations.GwtCompatible; 20090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 21090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/** 22090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * "Overrides" the {@link ImmutableSet} static methods that lack 23090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@link ImmutableSortedSet} equivalents with deprecated, exception-throwing 241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * versions. This prevents accidents like the following: <pre> {@code 25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * List<Object> objects = ...; 27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * // Sort them: 28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Set<Object> sorted = ImmutableSortedSet.copyOf(objects); 29090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * // BAD CODE! The returned set is actually an unsorted ImmutableSet!}</pre> 30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * While we could put the overrides in {@link ImmutableSortedSet} itself, it 32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * seems clearer to separate these "do not call" methods from those intended for 33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * normal use. 34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 35090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Chris Povirk 36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 37090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible 38090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonabstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> { 39090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. Use {@link ImmutableSortedSet#naturalOrder}, which offers 41090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * better type-safety, instead. This method exists only to hide 42090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@link ImmutableSet#builder} from consumers of {@code ImmutableSortedSet}. 43090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 44090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 45090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers 46090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * better type-safety. 47090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 48090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson @Deprecated public static <E> ImmutableSortedSet.Builder<E> builder() { 49090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 50090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 51090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 52090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. <b>You are attempting to create a set that may contain a 54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-{@code Comparable} element.</b> Proper calls will resolve to the 55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * version in {@code ImmutableSortedSet}, not this dummy version. 56090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 58090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link 59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * ImmutableSortedSet#of(Comparable)}.</b> 60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 61090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson @Deprecated public static <E> ImmutableSortedSet<E> of(E element) { 62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 63090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 66090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. <b>You are attempting to create a set that may contain a 67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-{@code Comparable} element.</b> Proper calls will resolve to the 68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * version in {@code ImmutableSortedSet}, not this dummy version. 69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 70090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 71090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * ImmutableSortedSet#of(Comparable, Comparable)}.</b> 73090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson @Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2) { 75090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 76090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 77090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 78090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 79090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. <b>You are attempting to create a set that may contain a 80090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-{@code Comparable} element.</b> Proper calls will resolve to the 81090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * version in {@code ImmutableSortedSet}, not this dummy version. 82090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 83090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 84090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 85090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b> 86090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 87090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson @Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) { 88090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 89090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 90090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 91090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 92090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. <b>You are attempting to create a set that may contain a 93090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-{@code Comparable} element.</b> Proper calls will resolve to the 94090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * version in {@code ImmutableSortedSet}, not this dummy version. 95090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 96090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 97090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 98090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. 99090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * </b> 100090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 101090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson @Deprecated public static <E> ImmutableSortedSet<E> of( 102090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson E e1, E e2, E e3, E e4) { 103090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 104090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 105090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 106090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 107090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. <b>You are attempting to create a set that may contain a 108090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-{@code Comparable} element.</b> Proper calls will resolve to the 109090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * version in {@code ImmutableSortedSet}, not this dummy version. 110090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 111090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 112090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 113090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * ImmutableSortedSet#of( 114090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Comparable, Comparable, Comparable, Comparable, Comparable)}. </b> 115090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 116090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson @Deprecated public static <E> ImmutableSortedSet<E> of( 117090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson E e1, E e2, E e3, E e4, E e5) { 118090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 119090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 120090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 121090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /** 1221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a set that may contain a 1231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * non-{@code Comparable} element.</b> Proper calls will resolve to the 1241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * version in {@code ImmutableSortedSet}, not this dummy version. 1251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 1261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 1271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 1281d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, 1291d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable, Comparable, Comparable...)}. </b> 1301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 1311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated public static <E> ImmutableSortedSet<E> of( 1321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) { 1331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 1341d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 1351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 1361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 137090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Not supported. <b>You are attempting to create a set that may contain 138090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-{@code Comparable} elements.</b> Proper calls will resolve to the 139090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * version in {@code ImmutableSortedSet}, not this dummy version. 140090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 141090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @throws UnsupportedOperationException always 142090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link 1431d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedSet#copyOf(Comparable[])}.</b> 144090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 1451d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated public static <E> ImmutableSortedSet<E> copyOf(E[] elements) { 146090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson throw new UnsupportedOperationException(); 147090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson } 148090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson 149090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson /* 150090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here, 151090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * providing only the properly typed 152090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedSet (and 153090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * likewise for the Iterator equivalent). However, due to a change in Sun's 154090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * interpretation of the JLS (as described at 155090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler 156090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * available as of this writing rejects our attempts. To maintain 157090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * compatibility with that version and with any other compilers that interpret 158090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * the JLS similarly, there is no definition of copyOf() here, and the 159090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * definition in ImmutableSortedSet matches that in ImmutableSet. 160090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * 161090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * The result is that ImmutableSortedSet.copyOf() may be called on 162090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * non-Comparable elements. We have not discovered a better solution. In 163090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * retrospect, the static factory methods should have gone in a separate class 164090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * so that ImmutableSortedSet wouldn't "inherit" too-permissive factory 165090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * methods from ImmutableSet. 166090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */ 167090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson} 168