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 Wilson/**
20090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * "Overrides" the {@link ImmutableSet} static methods that lack
21090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * {@link ImmutableSortedSet} equivalents with deprecated, exception-throwing
221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * versions. This prevents accidents like the following: <pre>   {@code
23090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
24090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *   List<Object> objects = ...;
25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *   // Sort them:
26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *   Set<Object> sorted = ImmutableSortedSet.copyOf(objects);
27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *   // BAD CODE! The returned set is actually an unsorted ImmutableSet!}</pre>
28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
290888a09821a98ac0680fad765217302858e70fa4Paul Duffin * <p>While we could put the overrides in {@link ImmutableSortedSet} itself, it
30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * seems clearer to separate these "do not call" methods from those intended for
31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * normal use.
32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Chris Povirk
34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
35090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonabstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> {
36090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
37090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. Use {@link ImmutableSortedSet#naturalOrder}, which offers
38090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * better type-safety, instead. This method exists only to hide
39090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * {@link ImmutableSet#builder} from consumers of {@code ImmutableSortedSet}.
40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
41090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
42090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers
43090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     better type-safety.
44090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
450888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet.Builder<E> builder() {
46090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
47090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
48090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
49090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
50090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. <b>You are attempting to create a set that may contain a
51090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-{@code Comparable} element.</b> Proper calls will resolve to the
52090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * version in {@code ImmutableSortedSet}, not this dummy version.
53090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
54090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
55090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
56090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     ImmutableSortedSet#of(Comparable)}.</b>
57090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
580888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> of(E element) {
59090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
60090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
61090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
62090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
63090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. <b>You are attempting to create a set that may contain a
64090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-{@code Comparable} element.</b> Proper calls will resolve to the
65090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * version in {@code ImmutableSortedSet}, not this dummy version.
66090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
67090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
68090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
69090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     ImmutableSortedSet#of(Comparable, Comparable)}.</b>
70090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
710888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
72090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
73090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
74090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
75090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
76090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. <b>You are attempting to create a set that may contain a
77090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-{@code Comparable} element.</b> Proper calls will resolve to the
78090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * version in {@code ImmutableSortedSet}, not this dummy version.
79090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
80090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
81090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
82090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
83090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
840888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
85090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
86090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
87090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
88090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
89090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. <b>You are attempting to create a set that may contain a
90090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-{@code Comparable} element.</b> Proper calls will resolve to the
91090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * version in {@code ImmutableSortedSet}, not this dummy version.
92090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
93090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
94090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
95090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}.
96090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * </b>
97090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
980888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> of(
990888a09821a98ac0680fad765217302858e70fa4Paul Duffin      E e1, E e2, E e3, E e4) {
100090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
101090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
102090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
103090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
104090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. <b>You are attempting to create a set that may contain a
105090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-{@code Comparable} element.</b> Proper calls will resolve to the
106090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * version in {@code ImmutableSortedSet}, not this dummy version.
107090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
108090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
109090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
110090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     ImmutableSortedSet#of(
111090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *     Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
112090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
1130888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> of(
1140888a09821a98ac0680fad765217302858e70fa4Paul Duffin      E e1, E e2, E e3, E e4, E e5) {
115090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
116090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
117090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
118090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /**
1191d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * Not supported. <b>You are attempting to create a set that may contain a
1201d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * non-{@code Comparable} element.</b> Proper calls will resolve to the
1211d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * version in {@code ImmutableSortedSet}, not this dummy version.
1221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   *
1231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * @throws UnsupportedOperationException always
1241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
1251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   *     ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable,
1261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   *     Comparable, Comparable, Comparable...)}. </b>
1271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   */
1280888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> of(
1290888a09821a98ac0680fad765217302858e70fa4Paul Duffin      E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
1301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert    throw new UnsupportedOperationException();
1311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  }
1321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
1331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  /**
134090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * Not supported. <b>You are attempting to create a set that may contain
135090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-{@code Comparable} elements.</b> Proper calls will resolve to the
136090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * version in {@code ImmutableSortedSet}, not this dummy version.
137090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
138090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @throws UnsupportedOperationException always
139090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
1401d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   *     ImmutableSortedSet#copyOf(Comparable[])}.</b>
141090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
1420888a09821a98ac0680fad765217302858e70fa4Paul Duffin  @Deprecated public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
143090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    throw new UnsupportedOperationException();
144090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
145090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
146090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /*
147090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here,
148090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * providing only the properly typed
149090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedSet (and
150090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * likewise for the Iterator equivalent). However, due to a change in Sun's
151090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * interpretation of the JLS (as described at
152090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler
153090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * available as of this writing rejects our attempts. To maintain
154090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * compatibility with that version and with any other compilers that interpret
155090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * the JLS similarly, there is no definition of copyOf() here, and the
156090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * definition in ImmutableSortedSet matches that in ImmutableSet.
157090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   *
158090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * The result is that ImmutableSortedSet.copyOf() may be called on
159090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * non-Comparable elements. We have not discovered a better solution. In
160090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * retrospect, the static factory methods should have gone in a separate class
161090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * so that ImmutableSortedSet wouldn't "inherit" too-permissive factory
162090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * methods from ImmutableSet.
163090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
164090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson}
165