toJavaUtil() {
* Comparison to {@code java.util.Optional}: this method is equivalent to Java 8's
* {@code Optional.orElse(null)}.
*/
- @Nullable
- public abstract T orNull();
+ public abstract @Nullable T orNull();
/**
* Returns an immutable singleton {@link Set} whose only element is the contained instance if it
diff --git a/guava/src/com/google/common/base/StandardSystemProperty.java b/guava/src/com/google/common/base/StandardSystemProperty.java
index d0674cbbc4b9..7a7b11502fb1 100644
--- a/guava/src/com/google/common/base/StandardSystemProperty.java
+++ b/guava/src/com/google/common/base/StandardSystemProperty.java
@@ -125,8 +125,7 @@ public String key() {
* Returns the current value for this system property by delegating to {@link
* System#getProperty(String)}.
*/
- @Nullable
- public String value() {
+ public @Nullable String value() {
return System.getProperty(key);
}
diff --git a/guava/src/com/google/common/base/Strings.java b/guava/src/com/google/common/base/Strings.java
index d3207b5f2836..20d82488bcc7 100644
--- a/guava/src/com/google/common/base/Strings.java
+++ b/guava/src/com/google/common/base/Strings.java
@@ -47,8 +47,7 @@ public static String nullToEmpty(@Nullable String string) {
* @param string the string to test and possibly return
* @return {@code string} itself if it is nonempty; {@code null} if it is empty or null
*/
- @Nullable
- public static String emptyToNull(@Nullable String string) {
+ public static @Nullable String emptyToNull(@Nullable String string) {
return Platform.emptyToNull(string);
}
diff --git a/guava/src/com/google/common/base/Suppliers.java b/guava/src/com/google/common/base/Suppliers.java
index 6c4fc745958b..b602c880e34d 100644
--- a/guava/src/com/google/common/base/Suppliers.java
+++ b/guava/src/com/google/common/base/Suppliers.java
@@ -113,7 +113,7 @@ static class MemoizingSupplier implements Supplier, Serializable {
transient volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
- @Nullable transient T value;
+ transient @Nullable T value;
MemoizingSupplier(Supplier delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
@@ -214,7 +214,7 @@ public static Supplier memoizeWithExpiration(
static class ExpiringMemoizingSupplier implements Supplier, Serializable {
final Supplier delegate;
final long durationNanos;
- @Nullable transient volatile T value;
+ transient volatile @Nullable T value;
// The special value 0 means "not yet initialized".
transient volatile long expirationNanos;
@@ -266,7 +266,7 @@ public static Supplier ofInstance(@Nullable T instance) {
}
private static class SupplierOfInstance implements Supplier, Serializable {
- @Nullable final T instance;
+ final @Nullable T instance;
SupplierOfInstance(@Nullable T instance) {
this.instance = instance;
diff --git a/guava/src/com/google/common/base/Throwables.java b/guava/src/com/google/common/base/Throwables.java
index c8ace433700f..54152388b071 100644
--- a/guava/src/com/google/common/base/Throwables.java
+++ b/guava/src/com/google/common/base/Throwables.java
@@ -448,32 +448,30 @@ private static Object invokeAccessibleNonThrowingMethod(
/** Access to some fancy internal JVM internals. */
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static final Object jla = getJLA();
+ private static final @Nullable Object jla = getJLA();
/**
* The "getStackTraceElementMethod" method, only available on some JDKs so we use reflection to
* find it when available. When this is null, use the slow way.
*/
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static final Method getStackTraceElementMethod = (jla == null) ? null : getGetMethod();
+ private static final @Nullable Method getStackTraceElementMethod =
+ (jla == null) ? null : getGetMethod();
/**
* The "getStackTraceDepth" method, only available on some JDKs so we use reflection to find it
* when available. When this is null, use the slow way.
*/
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static final Method getStackTraceDepthMethod = (jla == null) ? null : getSizeMethod();
+ private static final @Nullable Method getStackTraceDepthMethod =
+ (jla == null) ? null : getSizeMethod();
/**
* Returns the JavaLangAccess class that is present in all Sun JDKs. It is not whitelisted for
* AppEngine, and not present in non-Sun JDKs.
*/
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static Object getJLA() {
+ private static @Nullable Object getJLA() {
try {
/*
* We load sun.misc.* classes using reflection since Android doesn't support these classes and
@@ -498,8 +496,7 @@ private static Object getJLA() {
* method cannot be found (it is only to be found in fairly recent JDKs).
*/
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static Method getGetMethod() {
+ private static @Nullable Method getGetMethod() {
return getJlaMethod("getStackTraceElement", Throwable.class, int.class);
}
@@ -513,8 +510,7 @@ private static Method getGetMethod() {
* UnsupportedOperationException.
*/
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static Method getSizeMethod() {
+ private static @Nullable Method getSizeMethod() {
try {
Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class);
if (getStackTraceDepth == null) {
@@ -528,8 +524,8 @@ private static Method getSizeMethod() {
}
@GwtIncompatible // java.lang.reflect
- @Nullable
- private static Method getJlaMethod(String name, Class>... parameterTypes) throws ThreadDeath {
+ private static @Nullable Method getJlaMethod(String name, Class>... parameterTypes)
+ throws ThreadDeath {
try {
return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes);
} catch (ThreadDeath death) {
diff --git a/guava/src/com/google/common/base/internal/Finalizer.java b/guava/src/com/google/common/base/internal/Finalizer.java
index 3b928d49686f..75d0d72f6ec4 100644
--- a/guava/src/com/google/common/base/internal/Finalizer.java
+++ b/guava/src/com/google/common/base/internal/Finalizer.java
@@ -116,11 +116,10 @@ public static void startFinalizer(
// By preference, we will use the Thread constructor that has an `inheritThreadLocals` parameter.
// But before Java 9, our only way not to inherit ThreadLocals is to zap them after the thread
// is created, by accessing a private field.
- @Nullable
- private static final Constructor bigThreadConstructor = getBigThreadConstructor();
+ private static final @Nullable Constructor bigThreadConstructor =
+ getBigThreadConstructor();
- @Nullable
- private static final Field inheritableThreadLocals =
+ private static final @Nullable Field inheritableThreadLocals =
(bigThreadConstructor == null) ? getInheritableThreadLocalsField() : null;
/** Constructs a new finalizer thread. */
@@ -192,8 +191,7 @@ private boolean cleanUp(Reference> reference) {
}
/** Looks up FinalizableReference.finalizeReferent() method. */
- @Nullable
- private Method getFinalizeReferentMethod() {
+ private @Nullable Method getFinalizeReferentMethod() {
Class> finalizableReferenceClass = finalizableReferenceClassReference.get();
if (finalizableReferenceClass == null) {
/*
@@ -211,8 +209,7 @@ private Method getFinalizeReferentMethod() {
}
}
- @Nullable
- private static Field getInheritableThreadLocalsField() {
+ private static @Nullable Field getInheritableThreadLocalsField() {
try {
Field inheritableThreadLocals = Thread.class.getDeclaredField("inheritableThreadLocals");
inheritableThreadLocals.setAccessible(true);
@@ -226,8 +223,7 @@ private static Field getInheritableThreadLocalsField() {
}
}
- @Nullable
- private static Constructor getBigThreadConstructor() {
+ private static @Nullable Constructor getBigThreadConstructor() {
try {
return Thread.class.getConstructor(
ThreadGroup.class, Runnable.class, String.class, long.class, boolean.class);
diff --git a/guava/src/com/google/common/cache/CacheBuilderSpec.java b/guava/src/com/google/common/cache/CacheBuilderSpec.java
index 39d94c817dc2..f332c90f864e 100644
--- a/guava/src/com/google/common/cache/CacheBuilderSpec.java
+++ b/guava/src/com/google/common/cache/CacheBuilderSpec.java
@@ -278,8 +278,7 @@ public boolean equals(@Nullable Object obj) {
* Converts an expiration duration/unit pair into a single Long for hashing and equality. Uses
* nanos to match CacheBuilder implementation.
*/
- @Nullable
- private static Long durationInNanos(long duration, @Nullable TimeUnit unit) {
+ private static @Nullable Long durationInNanos(long duration, @Nullable TimeUnit unit) {
return (unit == null) ? null : unit.toNanos(duration);
}
diff --git a/guava/src/com/google/common/cache/ForwardingCache.java b/guava/src/com/google/common/cache/ForwardingCache.java
index fa4f1a428da5..81dbf7acefa4 100644
--- a/guava/src/com/google/common/cache/ForwardingCache.java
+++ b/guava/src/com/google/common/cache/ForwardingCache.java
@@ -43,8 +43,7 @@ protected ForwardingCache() {}
/** @since 11.0 */
@Override
- @Nullable
- public V getIfPresent(Object key) {
+ public @Nullable V getIfPresent(Object key) {
return delegate().getIfPresent(key);
}
diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java
index f27e157a2cef..54472a0a7845 100644
--- a/guava/src/com/google/common/cache/LocalCache.java
+++ b/guava/src/com/google/common/cache/LocalCache.java
@@ -230,7 +230,7 @@ class LocalCache extends AbstractMap implements ConcurrentMap
final StatsCounter globalStatsCounter;
/** The default cache loader to use on loading operations. */
- @Nullable final CacheLoader super K, V> defaultLoader;
+ final @Nullable CacheLoader super K, V> defaultLoader;
/**
* Creates a new, empty map with the specified strategy, initial capacity and concurrency level.
@@ -953,7 +953,7 @@ public K getKey() {
// The code below is exactly the same for each entry type.
final int hash;
- @Nullable final ReferenceEntry next;
+ final @Nullable ReferenceEntry next;
volatile ValueReference valueReference = unset();
@Override
@@ -1240,7 +1240,7 @@ public void setPreviousInWriteQueue(ReferenceEntry previous) {
// The code below is exactly the same for each entry type.
final int hash;
- @Nullable final ReferenceEntry next;
+ final @Nullable ReferenceEntry next;
volatile ValueReference valueReference = unset();
@Override
@@ -1893,13 +1893,13 @@ static class Segment extends ReentrantLock {
* The key reference queue contains entries whose keys have been garbage collected, and which
* need to be cleaned up internally.
*/
- @Nullable final ReferenceQueue keyReferenceQueue;
+ final @Nullable ReferenceQueue keyReferenceQueue;
/**
* The value reference queue contains value references whose values have been garbage collected,
* and which need to be cleaned up internally.
*/
- @Nullable final ReferenceQueue valueReferenceQueue;
+ final @Nullable ReferenceQueue valueReferenceQueue;
/**
* The recency queue is used to record which entries were accessed for updating the access
@@ -3932,8 +3932,7 @@ public int size() {
}
@Override
- @Nullable
- public V get(@Nullable Object key) {
+ public @Nullable V get(@Nullable Object key) {
if (key == null) {
return null;
}
@@ -3946,8 +3945,7 @@ V get(K key, CacheLoader super K, V> loader) throws ExecutionException {
return segmentFor(hash).get(key, hash, loader);
}
- @Nullable
- public V getIfPresent(Object key) {
+ public @Nullable V getIfPresent(Object key) {
int hash = hash(checkNotNull(key));
V value = segmentFor(hash).get(key, hash);
if (value == null) {
@@ -3960,8 +3958,7 @@ public V getIfPresent(Object key) {
// Only becomes available in Java 8 when it's on the interface.
// @Override
- @Nullable
- public V getOrDefault(@Nullable Object key, @Nullable V defaultValue) {
+ public @Nullable V getOrDefault(@Nullable Object key, @Nullable V defaultValue) {
V result = get(key);
return (result != null) ? result : defaultValue;
}
@@ -4693,7 +4690,7 @@ static class ManualSerializationProxy extends ForwardingCache
final Weigher weigher;
final int concurrencyLevel;
final RemovalListener super K, ? super V> removalListener;
- @Nullable final Ticker ticker;
+ final @Nullable Ticker ticker;
final CacheLoader super K, V> loader;
@MonotonicNonNullDecl transient Cache delegate;
@@ -4857,8 +4854,7 @@ private LocalManualCache(LocalCache localCache) {
// Cache methods
@Override
- @Nullable
- public V getIfPresent(Object key) {
+ public @Nullable V getIfPresent(Object key) {
return localCache.getIfPresent(key);
}
diff --git a/guava/src/com/google/common/collect/AbstractIterator.java b/guava/src/com/google/common/collect/AbstractIterator.java
index c514bd063a01..ff009c528ddc 100644
--- a/guava/src/com/google/common/collect/AbstractIterator.java
+++ b/guava/src/com/google/common/collect/AbstractIterator.java
@@ -81,7 +81,7 @@ private enum State {
FAILED,
}
- @Nullable private T next;
+ private @Nullable T next;
/**
* Returns the next element. Note: the implementation must call {@link #endOfData()} when
diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
index 036cbd94b224..335102f19fcc 100644
--- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
@@ -324,10 +324,10 @@ final List wrapList(@Nullable K key, List list, @Nullable WrappedCollectio
*/
@WeakOuter
class WrappedCollection extends AbstractCollection {
- @Nullable final K key;
+ final @Nullable K key;
Collection delegate;
- @Nullable final WrappedCollection ancestor;
- @Nullable final Collection ancestorDelegate;
+ final @Nullable WrappedCollection ancestor;
+ final @Nullable Collection ancestorDelegate;
WrappedCollection(
@Nullable K key, Collection delegate, @Nullable WrappedCollection ancestor) {
diff --git a/guava/src/com/google/common/collect/AbstractNavigableMap.java b/guava/src/com/google/common/collect/AbstractNavigableMap.java
index 7004b7211fbf..b0200d7245b0 100644
--- a/guava/src/com/google/common/collect/AbstractNavigableMap.java
+++ b/guava/src/com/google/common/collect/AbstractNavigableMap.java
@@ -36,30 +36,25 @@ abstract class AbstractNavigableMap extends IteratorBasedAbstractMap
implements NavigableMap {
@Override
- @Nullable
- public abstract V get(@Nullable Object key);
+ public abstract @Nullable V get(@Nullable Object key);
@Override
- @Nullable
- public Entry firstEntry() {
+ public @Nullable Entry firstEntry() {
return Iterators.getNext(entryIterator(), null);
}
@Override
- @Nullable
- public Entry lastEntry() {
+ public @Nullable Entry lastEntry() {
return Iterators.getNext(descendingEntryIterator(), null);
}
@Override
- @Nullable
- public Entry pollFirstEntry() {
+ public @Nullable Entry pollFirstEntry() {
return Iterators.pollNext(entryIterator());
}
@Override
- @Nullable
- public Entry pollLastEntry() {
+ public @Nullable Entry pollLastEntry() {
return Iterators.pollNext(descendingEntryIterator());
}
@@ -84,26 +79,22 @@ public K lastKey() {
}
@Override
- @Nullable
- public Entry lowerEntry(K key) {
+ public @Nullable Entry lowerEntry(K key) {
return headMap(key, false).lastEntry();
}
@Override
- @Nullable
- public Entry floorEntry(K key) {
+ public @Nullable Entry floorEntry(K key) {
return headMap(key, true).lastEntry();
}
@Override
- @Nullable
- public Entry ceilingEntry(K key) {
+ public @Nullable Entry ceilingEntry(K key) {
return tailMap(key, true).firstEntry();
}
@Override
- @Nullable
- public Entry higherEntry(K key) {
+ public @Nullable Entry higherEntry(K key) {
return tailMap(key, false).firstEntry();
}
diff --git a/guava/src/com/google/common/collect/AbstractSequentialIterator.java b/guava/src/com/google/common/collect/AbstractSequentialIterator.java
index 05f561d68502..35a48641970f 100644
--- a/guava/src/com/google/common/collect/AbstractSequentialIterator.java
+++ b/guava/src/com/google/common/collect/AbstractSequentialIterator.java
@@ -41,7 +41,7 @@
*/
@GwtCompatible
public abstract class AbstractSequentialIterator extends UnmodifiableIterator {
- @Nullable private T nextOrNull;
+ private @Nullable T nextOrNull;
/**
* Creates a new iterator with the given first element, or, if {@code firstOrNull} is null,
diff --git a/guava/src/com/google/common/collect/ArrayTable.java b/guava/src/com/google/common/collect/ArrayTable.java
index 1a40c21cf909..0c873cc77ef4 100644
--- a/guava/src/com/google/common/collect/ArrayTable.java
+++ b/guava/src/com/google/common/collect/ArrayTable.java
@@ -190,11 +190,9 @@ K getKey(int index) {
abstract String getKeyRole();
- @Nullable
- abstract V getValue(int index);
+ abstract @Nullable V getValue(int index);
- @Nullable
- abstract V setValue(int index, V newValue);
+ abstract @Nullable V setValue(int index, V newValue);
@Override
public int size() {
diff --git a/guava/src/com/google/common/collect/CollectSpliterators.java b/guava/src/com/google/common/collect/CollectSpliterators.java
index f697a8d23e07..dcb5b46cc3f6 100644
--- a/guava/src/com/google/common/collect/CollectSpliterators.java
+++ b/guava/src/com/google/common/collect/CollectSpliterators.java
@@ -65,8 +65,7 @@ public void forEachRemaining(Consumer super T> action) {
}
@Override
- @Nullable
- public Spliterator trySplit() {
+ public @Nullable Spliterator trySplit() {
Spliterator.OfInt split = delegate.trySplit();
return (split == null) ? null : new WithCharacteristics(split);
}
diff --git a/guava/src/com/google/common/collect/CompactHashMap.java b/guava/src/com/google/common/collect/CompactHashMap.java
index ad8f54e02523..96fdfaba6151 100644
--- a/guava/src/com/google/common/collect/CompactHashMap.java
+++ b/guava/src/com/google/common/collect/CompactHashMap.java
@@ -236,8 +236,7 @@ void accessEntry(int index) {
@CanIgnoreReturnValue
@Override
- @Nullable
- public V put(@Nullable K key, @Nullable V value) {
+ public @Nullable V put(@Nullable K key, @Nullable V value) {
long[] entries = this.entries;
Object[] keys = this.keys;
Object[] values = this.values;
@@ -373,13 +372,11 @@ public V get(@Nullable Object key) {
@CanIgnoreReturnValue
@Override
- @Nullable
- public V remove(@Nullable Object key) {
+ public @Nullable V remove(@Nullable Object key) {
return remove(key, smearedHash(key));
}
- @Nullable
- private V remove(@Nullable Object key, int hash) {
+ private @Nullable V remove(@Nullable Object key, int hash) {
int tableIndex = hash & hashTableMask();
int next = table[tableIndex];
if (next == UNSET) { // empty bucket
@@ -664,7 +661,7 @@ Entry getOutput(int entry) {
}
final class MapEntry extends AbstractMapEntry {
- @Nullable private final K key;
+ private final @Nullable K key;
private int lastKnownIndex;
diff --git a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
index ab49e9aa97ef..3aaa76e3da3f 100644
--- a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
+++ b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
@@ -522,7 +522,7 @@ protected Entry computeNext() {
};
return new ForwardingIterator>() {
- @Nullable private Entry last;
+ private @Nullable Entry last;
@Override
protected Iterator> delegate() {
diff --git a/guava/src/com/google/common/collect/Cut.java b/guava/src/com/google/common/collect/Cut.java
index 3a12b2473a76..8f6cd818f738 100644
--- a/guava/src/com/google/common/collect/Cut.java
+++ b/guava/src/com/google/common/collect/Cut.java
@@ -33,7 +33,7 @@
*/
@GwtCompatible
abstract class Cut implements Comparable>, Serializable {
- @Nullable final C endpoint;
+ final @Nullable C endpoint;
Cut(@Nullable C endpoint) {
this.endpoint = endpoint;
diff --git a/guava/src/com/google/common/collect/DenseImmutableTable.java b/guava/src/com/google/common/collect/DenseImmutableTable.java
index 2e2688a99a81..af7cd5f94a7a 100644
--- a/guava/src/com/google/common/collect/DenseImmutableTable.java
+++ b/guava/src/com/google/common/collect/DenseImmutableTable.java
@@ -101,8 +101,7 @@ K getKey(int index) {
return keyToIndex().keySet().asList().get(index);
}
- @Nullable
- abstract V getValue(int keyIndex);
+ abstract @Nullable V getValue(int keyIndex);
@Override
ImmutableSet createKeySet() {
diff --git a/guava/src/com/google/common/collect/GeneralRange.java b/guava/src/com/google/common/collect/GeneralRange.java
index 697769ace6e6..29248a38a784 100644
--- a/guava/src/com/google/common/collect/GeneralRange.java
+++ b/guava/src/com/google/common/collect/GeneralRange.java
@@ -92,10 +92,10 @@ static GeneralRange range(
private final Comparator super T> comparator;
private final boolean hasLowerBound;
- @Nullable private final T lowerEndpoint;
+ private final @Nullable T lowerEndpoint;
private final BoundType lowerBoundType;
private final boolean hasUpperBound;
- @Nullable private final T upperEndpoint;
+ private final @Nullable T upperEndpoint;
private final BoundType upperBoundType;
private GeneralRange(
diff --git a/guava/src/com/google/common/collect/HashBiMap.java b/guava/src/com/google/common/collect/HashBiMap.java
index c1c4bf6046c1..af6091d84a3c 100644
--- a/guava/src/com/google/common/collect/HashBiMap.java
+++ b/guava/src/com/google/common/collect/HashBiMap.java
@@ -105,8 +105,8 @@ private static final class BiEntry extends ImmutableEntry {
private transient BiEntry[] hashTableKToV;
private transient BiEntry[] hashTableVToK;
- @Nullable private transient BiEntry firstInKeyInsertionOrder;
- @Nullable private transient BiEntry lastInKeyInsertionOrder;
+ private transient @Nullable BiEntry firstInKeyInsertionOrder;
+ private transient @Nullable BiEntry lastInKeyInsertionOrder;
private transient int size;
private transient int mask;
private transient int modCount;
@@ -249,9 +249,8 @@ public boolean containsValue(@Nullable Object value) {
return seekByValue(value, smearedHash(value)) != null;
}
- @Nullable
@Override
- public V get(@Nullable Object key) {
+ public @Nullable V get(@Nullable Object key) {
return Maps.valueOrNull(seekByKey(key, smearedHash(key)));
}
@@ -301,8 +300,7 @@ public V forcePut(@Nullable K key, @Nullable V value) {
return put(key, value, true);
}
- @Nullable
- private K putInverse(@Nullable V value, @Nullable K key, boolean force) {
+ private @Nullable K putInverse(@Nullable V value, @Nullable K key, boolean force) {
int valueHash = smearedHash(value);
int keyHash = smearedHash(key);
diff --git a/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java b/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
index b775baa23c3f..8a108b34d1f7 100644
--- a/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
+++ b/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
@@ -169,8 +169,7 @@ protected Map, B> delegate() {
@Override
@SuppressWarnings("unchecked") // value could not get in if not a T
- @Nullable
- public T getInstance(Class type) {
+ public @Nullable T getInstance(Class type) {
return (T) delegate.get(checkNotNull(type));
}
diff --git a/guava/src/com/google/common/collect/ImmutableEntry.java b/guava/src/com/google/common/collect/ImmutableEntry.java
index 5122e08019bf..0f435e97069a 100644
--- a/guava/src/com/google/common/collect/ImmutableEntry.java
+++ b/guava/src/com/google/common/collect/ImmutableEntry.java
@@ -23,23 +23,21 @@
/** @see com.google.common.collect.Maps#immutableEntry(Object, Object) */
@GwtCompatible(serializable = true)
class ImmutableEntry extends AbstractMapEntry implements Serializable {
- @Nullable final K key;
- @Nullable final V value;
+ final @Nullable K key;
+ final @Nullable V value;
ImmutableEntry(@Nullable K key, @Nullable V value) {
this.key = key;
this.value = value;
}
- @Nullable
@Override
- public final K getKey() {
+ public final @Nullable K getKey() {
return key;
}
- @Nullable
@Override
- public final V getValue() {
+ public final @Nullable V getValue() {
return value;
}
diff --git a/guava/src/com/google/common/collect/ImmutableMapEntry.java b/guava/src/com/google/common/collect/ImmutableMapEntry.java
index 8d5eb84ad971..d03d4fa0ea81 100644
--- a/guava/src/com/google/common/collect/ImmutableMapEntry.java
+++ b/guava/src/com/google/common/collect/ImmutableMapEntry.java
@@ -80,8 +80,7 @@ static class NonTerminalImmutableMapEntry extends ImmutableMapEntry
}
@Override
- @Nullable
- final ImmutableMapEntry getNextInKeyBucket() {
+ final @Nullable ImmutableMapEntry getNextInKeyBucket() {
return nextInKeyBucket;
}
diff --git a/guava/src/com/google/common/collect/ImmutableRangeMap.java b/guava/src/com/google/common/collect/ImmutableRangeMap.java
index 9d758d9a4357..5ebf0f4e4e5d 100644
--- a/guava/src/com/google/common/collect/ImmutableRangeMap.java
+++ b/guava/src/com/google/common/collect/ImmutableRangeMap.java
@@ -169,8 +169,7 @@ public ImmutableRangeMap build() {
}
@Override
- @Nullable
- public V get(K key) {
+ public @Nullable V get(K key) {
int index =
SortedLists.binarySearch(
ranges,
@@ -187,8 +186,7 @@ public V get(K key) {
}
@Override
- @Nullable
- public Entry, V> getEntry(K key) {
+ public @Nullable Entry, V> getEntry(K key) {
int index =
SortedLists.binarySearch(
ranges,
diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java
index 9af82851ca13..56a78f95414c 100644
--- a/guava/src/com/google/common/collect/ImmutableSet.java
+++ b/guava/src/com/google/common/collect/ImmutableSet.java
@@ -302,7 +302,7 @@ public int hashCode() {
@Override
public abstract UnmodifiableIterator iterator();
- @LazyInit @Nullable @RetainedWith private transient ImmutableList asList;
+ @LazyInit @RetainedWith private transient @Nullable ImmutableList asList;
@Override
public ImmutableList asList() {
diff --git a/guava/src/com/google/common/collect/Iterables.java b/guava/src/com/google/common/collect/Iterables.java
index 2f000b6e6ffc..5313b49e9111 100644
--- a/guava/src/com/google/common/collect/Iterables.java
+++ b/guava/src/com/google/common/collect/Iterables.java
@@ -199,8 +199,8 @@ public static boolean removeIf(Iterable removeFrom, Predicate super T>
}
/** Removes and returns the first matching element, or returns {@code null} if there is none. */
- @Nullable
- static T removeFirstMatching(Iterable removeFrom, Predicate super T> predicate) {
+ static @Nullable T removeFirstMatching(
+ Iterable removeFrom, Predicate super T> predicate) {
checkNotNull(predicate);
Iterator iterator = removeFrom.iterator();
while (iterator.hasNext()) {
@@ -263,8 +263,8 @@ public static T getOnlyElement(Iterable iterable) {
*
* @throws IllegalArgumentException if the iterator contains multiple elements
*/
- @Nullable
- public static T getOnlyElement(Iterable extends T> iterable, @Nullable T defaultValue) {
+ public static @Nullable T getOnlyElement(
+ Iterable extends T> iterable, @Nullable T defaultValue) {
return Iterators.getOnlyElement(iterable.iterator(), defaultValue);
}
@@ -641,8 +641,7 @@ public static T find(Iterable iterable, Predicate super T> predicate) {
*
* @since 7.0
*/
- @Nullable
- public static T find(
+ public static @Nullable T find(
Iterable extends T> iterable, Predicate super T> predicate, @Nullable T defaultValue) {
return Iterators.find(iterable.iterator(), predicate, defaultValue);
}
@@ -745,8 +744,8 @@ public static T get(Iterable iterable, int position) {
* @throws IndexOutOfBoundsException if {@code position} is negative
* @since 4.0
*/
- @Nullable
- public static T get(Iterable extends T> iterable, int position, @Nullable T defaultValue) {
+ public static @Nullable T get(
+ Iterable extends T> iterable, int position, @Nullable T defaultValue) {
checkNotNull(iterable);
Iterators.checkNonnegative(position);
if (iterable instanceof List) {
@@ -776,8 +775,7 @@ public static T get(Iterable extends T> iterable, int position, @Nullable
* @return the first element of {@code iterable} or the default value
* @since 7.0
*/
- @Nullable
- public static T getFirst(Iterable extends T> iterable, @Nullable T defaultValue) {
+ public static @Nullable T getFirst(Iterable extends T> iterable, @Nullable T defaultValue) {
return Iterators.getNext(iterable.iterator(), defaultValue);
}
@@ -814,8 +812,7 @@ public static T getLast(Iterable iterable) {
* @return the last element of {@code iterable} or the default value
* @since 3.0
*/
- @Nullable
- public static T getLast(Iterable extends T> iterable, @Nullable T defaultValue) {
+ public static @Nullable T getLast(Iterable extends T> iterable, @Nullable T defaultValue) {
if (iterable instanceof Collection) {
Collection extends T> c = Collections2.cast(iterable);
if (c.isEmpty()) {
diff --git a/guava/src/com/google/common/collect/Iterators.java b/guava/src/com/google/common/collect/Iterators.java
index 9bbaeec1983e..f8cc4628e1ed 100644
--- a/guava/src/com/google/common/collect/Iterators.java
+++ b/guava/src/com/google/common/collect/Iterators.java
@@ -324,8 +324,8 @@ public static T getOnlyElement(Iterator iterator) {
* iterator is unspecified.
*/
@CanIgnoreReturnValue // TODO(kak): Consider removing this?
- @Nullable
- public static T getOnlyElement(Iterator extends T> iterator, @Nullable T defaultValue) {
+ public static @Nullable T getOnlyElement(
+ Iterator extends T> iterator, @Nullable T defaultValue) {
return iterator.hasNext() ? getOnlyElement(iterator) : defaultValue;
}
@@ -707,8 +707,7 @@ public static T find(Iterator iterator, Predicate super T> predicate) {
*
* @since 7.0
*/
- @Nullable
- public static T find(
+ public static @Nullable T find(
Iterator extends T> iterator, Predicate super T> predicate, @Nullable T defaultValue) {
checkNotNull(iterator);
checkNotNull(predicate);
@@ -823,8 +822,8 @@ public static T get(Iterator iterator, int position) {
* @throws IndexOutOfBoundsException if {@code position} is negative
* @since 4.0
*/
- @Nullable
- public static T get(Iterator extends T> iterator, int position, @Nullable T defaultValue) {
+ public static @Nullable T get(
+ Iterator extends T> iterator, int position, @Nullable T defaultValue) {
checkNonnegative(position);
advance(iterator, position);
return getNext(iterator, defaultValue);
@@ -844,8 +843,7 @@ static void checkNonnegative(int position) {
* @return the next element of {@code iterator} or the default value
* @since 7.0
*/
- @Nullable
- public static T getNext(Iterator extends T> iterator, @Nullable T defaultValue) {
+ public static @Nullable T getNext(Iterator extends T> iterator, @Nullable T defaultValue) {
return iterator.hasNext() ? iterator.next() : defaultValue;
}
@@ -872,8 +870,7 @@ public static T getLast(Iterator iterator) {
* @return the last element of {@code iterator}
* @since 3.0
*/
- @Nullable
- public static T getLast(Iterator extends T> iterator, @Nullable T defaultValue) {
+ public static @Nullable T getLast(Iterator extends T> iterator, @Nullable T defaultValue) {
return iterator.hasNext() ? getLast(iterator) : defaultValue;
}
@@ -970,8 +967,7 @@ public String toString() {
* Deletes and returns the next value from the iterator, or returns {@code null} if there is no
* such value.
*/
- @Nullable
- static T pollNext(Iterator iterator) {
+ static @Nullable T pollNext(Iterator iterator) {
if (iterator.hasNext()) {
T result = iterator.next();
iterator.remove();
@@ -1051,7 +1047,7 @@ protected T get(int index) {
*
* The {@link Iterable} equivalent of this method is {@link Collections#singleton}.
*/
- public static UnmodifiableIterator singletonIterator(@Nullable final T value) {
+ public static UnmodifiableIterator singletonIterator(final @Nullable T value) {
return new UnmodifiableIterator() {
boolean done;
@@ -1119,7 +1115,7 @@ private static class PeekingImpl implements PeekingIterator {
private final Iterator extends E> iterator;
private boolean hasPeeked;
- @Nullable private E peekedElement;
+ private @Nullable E peekedElement;
public PeekingImpl(Iterator extends E> iterator) {
this.iterator = checkNotNull(iterator);
@@ -1288,7 +1284,7 @@ public T next() {
private static class ConcatenatedIterator implements Iterator {
/* The last iterator to return an element. Calls to remove() go to this iterator. */
- @Nullable private Iterator extends T> toRemove;
+ private @Nullable Iterator extends T> toRemove;
/* The iterator currently returning elements. */
private Iterator extends T> iterator;
@@ -1303,7 +1299,7 @@ private static class ConcatenatedIterator implements Iterator {
private Iterator extends Iterator extends T>> topMetaIterator;
// Only becomes nonnull if we encounter nested concatenations.
- @Nullable private Deque>> metaIterators;
+ private @Nullable Deque>> metaIterators;
ConcatenatedIterator(Iterator extends Iterator extends T>> metaIterator) {
iterator = emptyIterator();
@@ -1311,8 +1307,7 @@ private static class ConcatenatedIterator implements Iterator {
}
// Returns a nonempty meta-iterator or, if all meta-iterators are empty, null.
- @Nullable
- private Iterator extends Iterator extends T>> getTopMetaIterator() {
+ private @Nullable Iterator extends Iterator extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
topMetaIterator = metaIterators.removeFirst();
diff --git a/guava/src/com/google/common/collect/LinkedListMultimap.java b/guava/src/com/google/common/collect/LinkedListMultimap.java
index 18489fc5d93d..821c84a6e618 100644
--- a/guava/src/com/google/common/collect/LinkedListMultimap.java
+++ b/guava/src/com/google/common/collect/LinkedListMultimap.java
@@ -106,7 +106,7 @@ public class LinkedListMultimap extends AbstractMultimap
*/
private static final class Node extends AbstractMapEntry {
- @Nullable final K key;
+ final @Nullable K key;
@Nullable V value;
@Nullable Node next; // the next node (with any key)
@Nullable Node previous; // the previous node (with any key)
@@ -150,8 +150,8 @@ private static class KeyList {
}
}
- @Nullable private transient Node head; // the head for all keys
- @Nullable private transient Node tail; // the tail for all keys
+ private transient @Nullable Node head; // the head for all keys
+ private transient @Nullable Node tail; // the tail for all keys
private transient Map> keyToKeyList;
private transient int size;
@@ -454,7 +454,7 @@ public void remove() {
/** A {@code ListIterator} over values for a specified key. */
private class ValueForKeyIterator implements ListIterator {
- @Nullable final Object key;
+ final @Nullable Object key;
int nextIndex;
@Nullable Node next;
@Nullable Node current;
diff --git a/guava/src/com/google/common/collect/Lists.java b/guava/src/com/google/common/collect/Lists.java
index a5256a6ddbe4..4f895325069d 100644
--- a/guava/src/com/google/common/collect/Lists.java
+++ b/guava/src/com/google/common/collect/Lists.java
@@ -314,7 +314,7 @@ public static List asList(@Nullable E first, @Nullable E second, E[] rest
/** @see Lists#asList(Object, Object[]) */
private static class OnePlusArrayList extends AbstractList
implements Serializable, RandomAccess {
- @Nullable final E first;
+ final @Nullable E first;
final E[] rest;
OnePlusArrayList(@Nullable E first, E[] rest) {
@@ -340,8 +340,8 @@ public E get(int index) {
/** @see Lists#asList(Object, Object, Object[]) */
private static class TwoPlusArrayList extends AbstractList
implements Serializable, RandomAccess {
- @Nullable final E first;
- @Nullable final E second;
+ final @Nullable E first;
+ final @Nullable E second;
final E[] rest;
TwoPlusArrayList(@Nullable E first, @Nullable E second, E[] rest) {
diff --git a/guava/src/com/google/common/collect/MapMakerInternalMap.java b/guava/src/com/google/common/collect/MapMakerInternalMap.java
index 54ead3944277..899190443b91 100644
--- a/guava/src/com/google/common/collect/MapMakerInternalMap.java
+++ b/guava/src/com/google/common/collect/MapMakerInternalMap.java
@@ -340,7 +340,7 @@ abstract static class AbstractStrongKeyEntry {
final K key;
final int hash;
- @Nullable final E next;
+ final @Nullable E next;
AbstractStrongKeyEntry(K key, int hash, @Nullable E next) {
this.key = key;
@@ -390,15 +390,14 @@ WeakValueReference unsetWeakValueReference() {
static final class StrongKeyStrongValueEntry
extends AbstractStrongKeyEntry>
implements StrongValueEntry> {
- @Nullable private volatile V value = null;
+ private volatile @Nullable V value = null;
StrongKeyStrongValueEntry(K key, int hash, @Nullable StrongKeyStrongValueEntry next) {
super(key, hash, next);
}
@Override
- @Nullable
- public V getValue() {
+ public @Nullable V getValue() {
return value;
}
@@ -647,7 +646,7 @@ public StrongKeyDummyValueEntry newEntry(
abstract static class AbstractWeakKeyEntry>
extends WeakReference