/** * Helper interface to implement both {@link ListenableFuture} and {@link ScheduledFuture}. * * @author Anthony Zana * @since 15.0 */ @Beta @GwtCompatible public interface ListenableScheduledFuture<V> extends ScheduledFuture<V>, ListenableFuture<V> {}
/** * Returns whether {@link #lazyStackTrace} will use the special implementation described in its * documentation. * * @since 19.0 */ @Beta @GwtIncompatible // getStackTraceElementMethod public static boolean lazyStackTraceIsLazy() { return getStackTraceElementMethod != null && getStackTraceDepthMethod != null; }
/** Returns the file holding the data (possibly null). */ @VisibleForTesting synchronized File getFile() { return file; }
@GwtIncompatible // not used in GWT @Override boolean isHashCodeFast() { return true; }
/** * Creates sets, containing sample elements, to be tested. * * @author Kevin Bourrillion */ @GwtCompatible public interface TestSetGenerator<E> extends TestCollectionGenerator<E> { @Override Set<E> create(Object... elements); }
/** Suppression strategy interface. */ @VisibleForTesting interface Suppressor { /** * Suppresses the given exception ({@code suppressed}) which was thrown when attempting to close * the given closeable. {@code thrown} is the exception that is actually being thrown from the * method. Implementations of this method should not throw under any circumstances. */ void suppress(Closeable closeable, Throwable thrown, Throwable suppressed); }
@GwtIncompatible // NavigableSet public static class ImmutableSortedSetDescendingGenerator extends TestStringSortedSetGenerator { @Override protected SortedSet<String> create(String[] elements) { return ImmutableSortedSet.<String>reverseOrder().add(elements).build().descendingSet(); } }
/** * Creates multisets, containing sample elements, to be tested. * * @author Jared Levy */ @GwtCompatible public interface TestMultisetGenerator<E> extends TestCollectionGenerator<E> { @Override Multiset<E> create(Object... elements); }
/** Suppresses exceptions by logging them. */ @VisibleForTesting static final class LoggingSuppressor implements Suppressor { static final LoggingSuppressor INSTANCE = new LoggingSuppressor(); @Override public void suppress(Closeable closeable, Throwable thrown, Throwable suppressed) { // log to the same place as Closeables Closeables.logger.log( Level.WARNING, "Suppressing exception thrown when closing " + closeable, suppressed); } }
@GwtIncompatible // serialization private static class SerializedForm<V> implements Serializable { final ImmutableMap<?, V> map; SerializedForm(ImmutableMap<?, V> map) { this.map = map; } Object readResolve() { return map.values(); } private static final long serialVersionUID = 0; } }
/** * Returns 1 if {@code x < y} as unsigned longs, and 0 otherwise. Assumes that x - y fits into a * signed long. The implementation is branch-free, and benchmarks suggest it is measurably faster * than the straightforward ternary expression. */ @VisibleForTesting static int lessThanBranchFree(long x, long y) { // Returns the sign bit of x - y. return (int) (~~(x - y) >>> (Long.SIZE - 1)); }
@GwtIncompatible // serialization private static class KeySetSerializedForm<K> implements Serializable { final ImmutableMap<K, ?> map; KeySetSerializedForm(ImmutableMap<K, ?> map) { this.map = map; } Object readResolve() { return map.keySet(); } private static final long serialVersionUID = 0; } }
/** * Returns 1 if {@code x < y} as unsigned integers, and 0 otherwise. Assumes that x - y fits into * a signed int. The implementation is branch-free, and benchmarks suggest it is measurably (if * narrowly) faster than the straightforward ternary expression. */ @VisibleForTesting static int lessThanBranchFree(int x, int y) { // The double negation is optimized away by normal Java, but is necessary for GWT // to make sure bit twiddling works as expected. return ~~(x - y) >>> (Integer.SIZE - 1); }
@GwtIncompatible // serialization private static class EntrySetSerializedForm<K, V> implements Serializable { final ImmutableMap<K, V> map; EntrySetSerializedForm(ImmutableMap<K, V> map) { this.map = map; } Object readResolve() { return map.entrySet(); } private static final long serialVersionUID = 0; } }
@VisibleForTesting WithExplicitOrdering(Policy policy, Map<E, LockGraphNode> lockGraphNodes) { super(policy); this.lockGraphNodes = lockGraphNodes; }
@GwtIncompatible // used only from suite public static final class ImmutableLongArrayHeadSubListAsListGenerator extends TestLongListGenerator { @Override protected List<Long> create(Long[] elements) { Long[] suffix = {Long.MIN_VALUE, Long.MAX_VALUE}; Long[] all = concat(elements, suffix); return makeArray(all).subArray(0, elements.length).asList(); } }
@GwtIncompatible // used only from suite public static final class ImmutableLongArrayTailSubListAsListGenerator extends TestLongListGenerator { @Override protected List<Long> create(Long[] elements) { Long[] prefix = {86L, 99L}; Long[] all = concat(prefix, elements); return makeArray(all).subArray(2, elements.length + 2).asList(); } }
@GwtIncompatible // Only used by @GwtIncompatible code private static class MultisetHolder implements Serializable { public Multiset<?> member; MultisetHolder(Multiset<?> multiset) { this.member = multiset; } private static final long serialVersionUID = 1L; }
@GwtIncompatible // Only used by @GwtIncompatible code private abstract static class SingletonIteratorTester extends IteratorTester<Integer> { protected SingletonIteratorTester() { super(3, MODIFIABLE, singleton(1), IteratorTester.KnownOrder.KNOWN_ORDER); } }
@GwtIncompatible // used only from suite public static final class ImmutableIntArrayAsListGenerator extends TestIntegerListGenerator { @Override protected List<Integer> create(Integer[] elements) { return makeArray(elements).asList(); } }