Skip to content

Commit

Permalink
Add @DoNotMock to several com.google.common types
Browse files Browse the repository at this point in the history
Relnotes:
  - Add @DoNotMock to several com.google.common types.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=284229762
  • Loading branch information
jlavallee authored and cgdecker committed Dec 9, 2019
1 parent ac12249 commit 4eea0f7
Show file tree
Hide file tree
Showing 64 changed files with 136 additions and 2 deletions.
Expand Up @@ -20,6 +20,7 @@

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.DoNotMock;
import com.google.j2objc.annotations.J2ObjCIncompatible;
import java.lang.ref.WeakReference;
import java.util.Locale;
Expand Down Expand Up @@ -241,6 +242,7 @@ protected void finalize() {
* <li>enqueuing weak references to unreachable referents in their reference queue
* </ul>
*/
@DoNotMock("Implement with a lambda")
public interface FinalizationPredicate {
boolean isDone();
}
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.google.common.testing;

import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import com.google.common.annotations.GwtCompatible;

/**
Expand All @@ -26,6 +27,7 @@
* @since 10.0
*/
@Beta
@DoNotMock("Implement with a lambda")
@GwtCompatible
public interface TearDownAccepter {
/**
Expand Down
Expand Up @@ -15,6 +15,7 @@
package com.google.common.base;

import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.DoNotMock;

/**
* Implemented by references that have code to run after garbage collection of their referents.
Expand All @@ -23,6 +24,7 @@
* @author Bob Lee
* @since 2.0
*/
@DoNotMock("Use an instance of one of the Finalizable*Reference classes")
@GwtIncompatible
public interface FinalizableReference {
/**
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/base/Optional.java
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
Expand Down Expand Up @@ -79,6 +80,7 @@
* @author Kevin Bourrillion
* @since 10.0
*/
@DoNotMock("Use Optional.of(value) or Optional.absent()")
@GwtCompatible(serializable = true)
public abstract class Optional<T> implements Serializable {
/**
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/cache/Cache.java
Expand Up @@ -19,6 +19,7 @@
import com.google.common.util.concurrent.ExecutionError;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.google.errorprone.annotations.CompatibleWith;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
Expand All @@ -36,6 +37,7 @@
* @author Charles Fry
* @since 10.0
*/
@DoNotMock("Use CacheBuilder.newBuilder().build()")
@GwtCompatible
public interface Cache<K, V> {

Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;

Expand All @@ -40,6 +41,7 @@
* @author Kevin Bourrillion
* @since 2.0
*/
@DoNotMock("Use ImmutableClassToInstanceMap or MutableClassToInstanceMap")
@GwtCompatible
public interface ClassToInstanceMap<B> extends Map<Class<? extends B>, B> {
/**
Expand Down
Expand Up @@ -22,6 +22,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Arrays;
Expand Down Expand Up @@ -157,6 +158,7 @@
*
* @since 2.0
*/
@DoNotMock("Use ImmutableList.of or another implementation")
@GwtCompatible(emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
// TODO(kevinb): I think we should push everything down to "BaseImmutableCollection" or something,
Expand Down Expand Up @@ -340,6 +342,7 @@ Object writeReplace() {
*
* @since 10.0
*/
@DoNotMock
public abstract static class Builder<E> {
static final int DEFAULT_INITIAL_CAPACITY = 4;

Expand Down
3 changes: 3 additions & 0 deletions android/guava/src/com/google/common/collect/ImmutableMap.java
Expand Up @@ -24,6 +24,7 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import com.google.j2objc.annotations.WeakOuter;
Expand Down Expand Up @@ -51,6 +52,7 @@
* @author Kevin Bourrillion
* @since 2.0
*/
@DoNotMock("Use ImmutableMap.of or another implementation")
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
Expand Down Expand Up @@ -208,6 +210,7 @@ static IllegalArgumentException conflictException(
*
* @since 2.0
*/
@DoNotMock
public static class Builder<K, V> {
@MonotonicNonNullDecl Comparator<? super V> valueComparator;
Object[] alternatingKeysAndValues;
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import com.google.j2objc.annotations.Weak;
import com.google.j2objc.annotations.WeakOuter;
import java.io.Serializable;
Expand Down Expand Up @@ -136,6 +137,7 @@ public static <K, V> Builder<K, V> builder() {
*
* @since 2.0
*/
@DoNotMock
public static class Builder<K, V> {
Map<K, Collection<V>> builderMap;
@MonotonicNonNullDecl Comparator<? super K> keyComparator;
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.google.common.collect.SortedLists.KeyAbsentBehavior;
import com.google.common.collect.SortedLists.KeyPresentBehavior;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -82,6 +83,7 @@ public static <K extends Comparable<?>, V> Builder<K, V> builder() {
*
* @since 14.0
*/
@DoNotMock
public static final class Builder<K extends Comparable<?>, V> {
private final List<Entry<Range<K>, V>> entries;

Expand Down
Expand Up @@ -21,6 +21,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
Expand Down Expand Up @@ -131,6 +132,7 @@ static <R, C, V> Cell<R, C, V> cellOf(R rowKey, C columnKey, V value) {
*
* @since 11.0
*/
@DoNotMock
public static final class Builder<R, C, V> {
private final List<Cell<R, C, V>> cells = Lists.newArrayList();
@MonotonicNonNullDecl private Comparator<? super R> rowComparator;
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/Interner.java
Expand Up @@ -19,6 +19,7 @@
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;

/**
* Provides equivalent behavior to {@link String#intern} for other immutable types. Common
Expand All @@ -28,6 +29,7 @@
* @since 3.0
*/
@Beta
@DoNotMock("Use Interners.new*Interner")
@GwtIncompatible
public interface Interner<E> {
/**
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.google.common.collect;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Map;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;

Expand All @@ -26,6 +27,7 @@
* @author Kevin Bourrillion
* @since 2.0
*/
@DoNotMock("Use Maps.difference")
@GwtCompatible
public interface MapDifference<K, V> {
/**
Expand Down Expand Up @@ -84,6 +86,7 @@ public interface MapDifference<K, V> {
*
* @since 2.0
*/
@DoNotMock("Use Maps.difference")
interface ValueDifference<V> {
/** Returns the value from the left map (possibly null). */
V leftValue();
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/Multimap.java
Expand Up @@ -19,6 +19,7 @@
import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CompatibleWith;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -155,6 +156,7 @@
* @author Jared Levy
* @since 2.0
*/
@DoNotMock("Use ImmutableMultimap, HashMultimap, or another implementation")
@GwtCompatible
public interface Multimap<K, V> {
// Query Operations
Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Iterator;
import java.util.NoSuchElementException;

Expand All @@ -31,6 +32,7 @@
* @author Mick Killianey
* @since 2.0
*/
@DoNotMock("Use Iterators.peekingIterator")
@GwtCompatible
public interface PeekingIterator<E> extends Iterator<E> {
/**
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/RangeMap.java
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
Expand All @@ -35,6 +36,7 @@
* @since 14.0
*/
@Beta
@DoNotMock("Use ImmutableRangeMap or TreeRangeMap")
@GwtIncompatible
public interface RangeMap<K extends Comparable, V> {
/**
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/RangeSet.java
Expand Up @@ -16,6 +16,7 @@

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.DoNotMock;
import java.util.NoSuchElementException;
import java.util.Set;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
Expand Down Expand Up @@ -49,6 +50,7 @@
* @since 14.0
*/
@Beta
@DoNotMock("Use ImmutableRangeSet or TreeRangeSet")
@GwtIncompatible
public interface RangeSet<C extends Comparable> {

Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/Table.java
Expand Up @@ -20,6 +20,7 @@
import com.google.common.base.Objects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CompatibleWith;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -52,6 +53,7 @@
* @param <V> the type of the mapped values
* @since 7.0
*/
@DoNotMock("Use ImmutableTable, HashBasedTable, or another implementation")
@GwtCompatible
public interface Table<R, C, V> {
// TODO(jlevy): Consider adding methods similar to ConcurrentMap methods.
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/escape/Escaper.java
Expand Up @@ -16,6 +16,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.errorprone.annotations.DoNotMock;

/**
* An object that converts literal text into a format safe for inclusion in a particular context
Expand Down Expand Up @@ -53,6 +54,7 @@
* @author David Beaumont
* @since 15.0
*/
@DoNotMock("Use Escapers.nullEscaper() or another methods from the *Escapers classes")
@GwtCompatible
public abstract class Escaper {
// TODO(dbeaumont): evaluate custom implementations, considering package private constructor.
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/graph/Graph.java
Expand Up @@ -17,6 +17,7 @@
package com.google.common.graph;

import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Collection;
import java.util.Set;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
Expand Down Expand Up @@ -101,6 +102,7 @@
* @since 20.0
*/
@Beta
@DoNotMock("Use GraphBuilder to create a real instance")
public interface Graph<N> extends BaseGraph<N> {
//
// Graph-level accessors
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/graph/GraphBuilder.java
Expand Up @@ -22,6 +22,7 @@

import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.errorprone.annotations.DoNotMock;

/**
* A builder for constructing instances of {@link MutableGraph} or {@link ImmutableGraph} with
Expand Down Expand Up @@ -62,6 +63,7 @@
* @since 20.0
*/
@Beta
@DoNotMock
public final class GraphBuilder<N> extends AbstractGraphBuilder<N> {

/** Creates a new instance with the specified edge directionality. */
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/graph/Network.java
Expand Up @@ -17,6 +17,7 @@
package com.google.common.graph;

import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;
import java.util.Set;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;

Expand Down Expand Up @@ -101,6 +102,7 @@
* @since 20.0
*/
@Beta
@DoNotMock("Use NetworkBuilder to create a real instance")
public interface Network<N, E> extends SuccessorsFunction<N>, PredecessorsFunction<N> {
//
// Network-level accessors
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.google.common.graph;

import com.google.common.annotations.Beta;
import com.google.errorprone.annotations.DoNotMock;

/**
* A functional interface for <a
Expand Down Expand Up @@ -78,6 +79,7 @@
* @since 23.0
*/
@Beta
@DoNotMock("Implement with a lambda, or use GraphBuilder to build a Graph with the desired edges")
public interface PredecessorsFunction<N> {

/**
Expand Down

0 comments on commit 4eea0f7

Please sign in to comment.