All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.common.collect.ImmutableSortedMultisetFauxverideShim Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

There is a newer version: 34.0.0.Final
Show newest version
/*
 * Copyright (C) 2011 The Guava Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.common.collect;

import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.DoNotCall;
import java.util.function.Function;
import java.util.function.ToIntFunction;
import java.util.stream.Collector;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * "Overrides" the {@link ImmutableMultiset} static methods that lack {@link
 * ImmutableSortedMultiset} equivalents with deprecated, exception-throwing versions. This prevents
 * accidents like the following:
 *
 * 
{@code
 * List objects = ...;
 * // Sort them:
 * Set sorted = ImmutableSortedMultiset.copyOf(objects);
 * // BAD CODE! The returned multiset is actually an unsorted ImmutableMultiset!
 * }
 *
 * 

While we could put the overrides in {@link ImmutableSortedMultiset} itself, it seems clearer * to separate these "do not call" methods from those intended for normal use. * * @author Louis Wasserman */ @GwtIncompatible @ElementTypesAreNonnullByDefault abstract class ImmutableSortedMultisetFauxverideShim extends ImmutableMultiset { /** * Not supported. Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset} instead. This * method exists only to hide {@link ImmutableMultiset#toImmutableMultiset} from consumers of * {@code ImmutableSortedMultiset}. * * @throws UnsupportedOperationException always * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}. * @since 21.0 */ @DoNotCall("Use toImmutableSortedMultiset.") @Deprecated public static Collector> toImmutableMultiset() { throw new UnsupportedOperationException(); } /** * Not supported. Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset} instead. This * method exists only to hide {@link ImmutableMultiset#toImmutableMultiset} from consumers of * {@code ImmutableSortedMultiset}. * * @throws UnsupportedOperationException always * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}. * @since 22.0 */ @DoNotCall("Use toImmutableSortedMultiset.") @Deprecated public static Collector> toImmutableMultiset( Function elementFunction, ToIntFunction countFunction) { throw new UnsupportedOperationException(); } /** * Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better * type-safety, instead. This method exists only to hide {@link ImmutableMultiset#builder} from * consumers of {@code ImmutableSortedMultiset}. * * @throws UnsupportedOperationException always * @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety. */ @DoNotCall("Use naturalOrder.") @Deprecated public static ImmutableSortedMultiset.Builder builder() { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain a non-{@code * Comparable} element. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass a parameter of type {@code Comparable} to use {@link * ImmutableSortedMultiset#of(Comparable)}. */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset of(E element) { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain a non-{@code * Comparable} element. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass the parameters of type {@code Comparable} to use {@link * ImmutableSortedMultiset#of(Comparable, Comparable)}. */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset of(E e1, E e2) { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain a non-{@code * Comparable} element. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass the parameters of type {@code Comparable} to use {@link * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}. */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset of(E e1, E e2, E e3) { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain a non-{@code * Comparable} element. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass the parameters of type {@code Comparable} to use {@link * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset of(E e1, E e2, E e3, E e4) { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain a non-{@code * Comparable} element. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass the parameters of type {@code Comparable} to use {@link * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} . * */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset of(E e1, E e2, E e3, E e4, E e5) { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain a non-{@code * Comparable} element. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass the parameters of type {@code Comparable} to use {@link * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable, * Comparable, Comparable...)} . */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset of( E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) { throw new UnsupportedOperationException(); } /** * Not supported. You are attempting to create a multiset that may contain non-{@code * Comparable} elements. Proper calls will resolve to the version in {@code * ImmutableSortedMultiset}, not this dummy version. * * @throws UnsupportedOperationException always * @deprecated Pass parameters of type {@code Comparable} to use {@link * ImmutableSortedMultiset#copyOf(Comparable[])}. */ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)") @Deprecated public static ImmutableSortedMultiset copyOf(E[] elements) { throw new UnsupportedOperationException(); } /* * We would like to include an unsupported " copyOf(Iterable)" here, providing only the * properly typed "> copyOf(Iterable)" in ImmutableSortedMultiset (and * likewise for the Iterator equivalent). However, due to a change in Sun's interpretation of the * JLS (as described at http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler * available as of this writing rejects our attempts. To maintain compatibility with that version * and with any other compilers that interpret the JLS similarly, there is no definition of * copyOf() here, and the definition in ImmutableSortedMultiset matches that in * ImmutableMultiset. * * The result is that ImmutableSortedMultiset.copyOf() may be called on non-Comparable elements. * We have not discovered a better solution. In retrospect, the static factory methods should * have gone in a separate class so that ImmutableSortedMultiset wouldn't "inherit" * too-permissive factory methods from ImmutableMultiset. */ }