11d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/* 21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2011 The Guava Authors 31d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 41d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 51d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * in compliance with the License. You may obtain a copy of the License at 61d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 71d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 81d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 91d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Unless required by applicable law or agreed to in writing, software distributed under the 101d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 111d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * express or implied. See the License for the specific language governing permissions and 121d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * limitations under the License. 131d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 141d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 151d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertpackage com.google.common.collect; 161d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 171d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/** 181d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * "Overrides" the {@link ImmutableMultiset} static methods that lack 191d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * {@link ImmutableSortedMultiset} equivalents with deprecated, exception-throwing versions. This 201d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * prevents accidents like the following: 211d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * <pre> {@code 231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * List<Object> objects = ...; 251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * // Sort them: 261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Set<Object> sorted = ImmutableSortedMultiset.copyOf(objects); 271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * // BAD CODE! The returned multiset is actually an unsorted ImmutableMultiset!}</pre> 281d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 291d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * While we could put the overrides in {@link ImmutableSortedMultiset} itself, it seems clearer to 301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * separate these "do not call" methods from those intended for normal use. 311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @author Louis Wasserman 331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 341d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertabstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> { 351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better 371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * type-safety, instead. This method exists only to hide {@link ImmutableMultiset#builder} from 381d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * consumers of {@code ImmutableSortedMultiset}. 391d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 401d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 411d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety. 421d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 431d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 441d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset.Builder<E> builder() { 451d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 461d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 471d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 481d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 491d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code 501d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} element.</b> Proper calls will resolve to the version in {@code 511d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 521d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 531d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 541d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass a parameter of type {@code Comparable} to use 551d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * {@link ImmutableSortedMultiset#of(Comparable)}.</b> 561d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 571d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 581d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> of(E element) { 591d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 601d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 611d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 621d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 631d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code 641d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} element.</b> Proper calls will resolve to the version in {@code 651d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 661d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 671d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 681d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass the parameters of type {@code Comparable} to use 691d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * {@link ImmutableSortedMultiset#of(Comparable, Comparable)}.</b> 701d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 711d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 721d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) { 731d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 741d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 751d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 761d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 771d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code 781d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} element.</b> Proper calls will resolve to the version in {@code 791d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 801d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 811d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 821d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass the parameters of type {@code Comparable} to use 831d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * {@link ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b> 841d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 851d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 861d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) { 871d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 881d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 891d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 901d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 911d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code 921d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} element.</b> Proper calls will resolve to the version in {@code 931d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 941d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 951d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 961d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 971d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b> 981d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 991d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 1001d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) { 1011d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 1021d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 1031d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 1041d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 1051d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code 1061d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} element.</b> Proper calls will resolve to the version in {@code 1071d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 1081d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 1091d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 1101d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 1111d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, 1121d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable)} . </b> 1131d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 1141d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 1151d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) { 1161d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 1171d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 1181d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 1191d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 1201d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code 1211d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} element.</b> Proper calls will resolve to the version in {@code 1221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 1231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 1241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 1251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link 1261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, 1271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable, Comparable, Comparable...)} . </b> 1281d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 1291d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 1301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> of( 1311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e1, 1321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e2, 1331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e3, 1341d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e4, 1351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e5, 1361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E e6, 1371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert E... remaining) { 1381d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 1391d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 1401d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 1411d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 1421d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Not supported. <b>You are attempting to create a multiset that may contain non-{@code 1431d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Comparable} elements.</b> Proper calls will resolve to the version in {@code 1441d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableSortedMultiset}, not this dummy version. 1451d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 1461d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @throws UnsupportedOperationException always 1471d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @deprecated <b>Pass parameters of type {@code Comparable} to use 1481d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * {@link ImmutableSortedMultiset#copyOf(Comparable[])}.</b> 1491d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 1501d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert @Deprecated 1511d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) { 1521d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert throw new UnsupportedOperationException(); 1531d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert } 1541d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 1551d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /* 1561d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here, providing only the 1571d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * properly typed "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedMultiset (and 1581d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * likewise for the Iterator equivalent). However, due to a change in Sun's interpretation of the 1591d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * JLS (as described at http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler 1601d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * available as of this writing rejects our attempts. To maintain compatibility with that version 1611d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * and with any other compilers that interpret the JLS similarly, there is no definition of 1621d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * copyOf() here, and the definition in ImmutableSortedMultiset matches that in 1631d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * ImmutableMultiset. 1641d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 1651d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * The result is that ImmutableSortedMultiset.copyOf() may be called on non-Comparable elements. 1661d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * We have not discovered a better solution. In retrospect, the static factory methods should 1671d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * have gone in a separate class so that ImmutableSortedMultiset wouldn't "inherit" 1681d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * too-permissive factory methods from ImmutableMultiset. 1691d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 1701d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert} 171