Skip to content

Commit

Permalink
Inline *FauxverideShim classes into their subclasses.
Browse files Browse the repository at this point in the history
Way back in cl/12024317 / cl/12147166, these classes had to be separate because each defined a `copyOf` method, whose erasure matched that of a method declared in the subclass. But in cl/13495337, we removed those methods. At that point, we could have inlined the classes. But there was no need, and I sort of liked keeping these weird, do-not-call methods in a separate file. But the indirection is mildly confusing, such as in obscuring that `ImmutableSortedSet` extends `ImmutableSet.CachingAsList`, not just `ImmutableSet`.

RELNOTES=n/a
PiperOrigin-RevId: 572427348
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Oct 11, 2023
1 parent db3017f commit ca01197
Show file tree
Hide file tree
Showing 14 changed files with 1,136 additions and 1,479 deletions.
254 changes: 253 additions & 1 deletion android/guava/src/com/google/common/collect/ImmutableSortedMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
public final class ImmutableSortedMap<K, V> extends ImmutableMap<K, V>
implements NavigableMap<K, V> {

/*
Expand Down Expand Up @@ -1146,4 +1146,256 @@ private void readObject(ObjectInputStream stream) throws InvalidObjectException
// This class is never actually serialized directly, but we have to make the
// warning go away (and suppressing would suppress for all nested classes too)
private static final long serialVersionUID = 0;

/**
* Not supported. Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety,
* instead. This method exists only to hide {@link ImmutableMap#builder} from consumers of {@code
* ImmutableSortedMap}.
*
* @throws UnsupportedOperationException always
* @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
*/
@DoNotCall("Use naturalOrder")
@Deprecated
public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
throw new UnsupportedOperationException();
}

/**
* Not supported for ImmutableSortedMap.
*
* @throws UnsupportedOperationException always
* @deprecated Not supported for ImmutableSortedMap.
*/
@DoNotCall("Use naturalOrder (which does not accept an expected size)")
@Deprecated
public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain a non-{@code Comparable}
* key.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this dummy
* version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass a key of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object)}.</b>
*/
@DoNotCall("Pass a key of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls to will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8,
K k9,
V v9) {
throw new UnsupportedOperationException();
}

/**
* Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
* keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
* dummy version.
*
* @throws UnsupportedOperationException always
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
* Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8,
K k9,
V v9,
K k10,
V v10) {
throw new UnsupportedOperationException();
}

/**
* Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
*
* @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
*/
@DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> ofEntries(
Entry<? extends K, ? extends V>... entries) {
throw new UnsupportedOperationException();
}
}
Loading

0 comments on commit ca01197

Please sign in to comment.