Skip to content

Commit e219ab5

Browse files
Merge branch 'master' into test/map-entryset-stream-spliterator
2 parents aa631f2 + e5d1fb9 commit e219ab5

File tree

13 files changed

+55
-44
lines changed

13 files changed

+55
-44
lines changed

android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.common.annotations.J2ktIncompatible;
2626
import com.google.common.annotations.VisibleForTesting;
2727
import com.google.common.base.Joiner;
28-
import com.google.common.base.Objects;
2928
import com.google.common.collect.ArrayListMultimap;
3029
import com.google.common.collect.ImmutableList;
3130
import com.google.common.collect.ListMultimap;
@@ -50,6 +49,7 @@
5049
import java.util.HashSet;
5150
import java.util.List;
5251
import java.util.Map.Entry;
52+
import java.util.Objects;
5353
import java.util.Set;
5454
import junit.framework.Assert;
5555
import junit.framework.AssertionFailedError;
@@ -164,7 +164,7 @@ public <T> ClassSanityTester setDistinctValues(Class<T> type, T value1, T value2
164164
checkNotNull(type);
165165
checkNotNull(value1);
166166
checkNotNull(value2);
167-
checkArgument(!Objects.equal(value1, value2), "Duplicate value provided.");
167+
checkArgument(!Objects.equals(value1, value2), "Duplicate value provided.");
168168
distinctValues.replaceValues(type, ImmutableList.of(value1, value2));
169169
setDefault(type, value1);
170170
return this;
@@ -607,7 +607,7 @@ String reportItem(Item<?> item) {
607607
List<Object> newArgs = new ArrayList<>(args);
608608
Object newArg = argGenerators.get(i).generateFresh(params.get(i).getType());
609609

610-
if (newArg == null || Objects.equal(args.get(i), newArg)) {
610+
if (newArg == null || Objects.equals(args.get(i), newArg)) {
611611
if (params.get(i).getType().getRawType().isEnum()) {
612612
continue; // Nothing better we can do if it's single-value enum
613613
}
@@ -638,7 +638,7 @@ private List<Object> generateEqualFactoryArguments(
638638
// Two newFreshValueGenerator() instances should normally generate equal value sequence.
639639
Object shouldBeEqualArg = generateDummyArg(param, newFreshValueGenerator());
640640
if (arg != shouldBeEqualArg
641-
&& Objects.equal(arg, shouldBeEqualArg)
641+
&& Objects.equals(arg, shouldBeEqualArg)
642642
&& hashCodeInsensitiveToArgReference(factory, args, i, checkNotNull(shouldBeEqualArg))
643643
&& hashCodeInsensitiveToArgReference(
644644
factory, args, i, generateDummyArg(param, newFreshValueGenerator()))) {

android/guava/src/com/google/common/base/Equivalence.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.common.annotations.J2ktIncompatible;
2222
import com.google.errorprone.annotations.ForOverride;
2323
import java.io.Serializable;
24+
import java.util.Objects;
2425
import org.jspecify.annotations.NonNull;
2526
import org.jspecify.annotations.Nullable;
2627

@@ -316,14 +317,14 @@ public boolean equals(@Nullable Object obj) {
316317
}
317318
if (obj instanceof EquivalentToPredicate) {
318319
EquivalentToPredicate<?> that = (EquivalentToPredicate<?>) obj;
319-
return equivalence.equals(that.equivalence) && Objects.equal(target, that.target);
320+
return equivalence.equals(that.equivalence) && Objects.equals(target, that.target);
320321
}
321322
return false;
322323
}
323324

324325
@Override
325326
public int hashCode() {
326-
return Objects.hashCode(equivalence, target);
327+
return Objects.hash(equivalence, target);
327328
}
328329

329330
@Override

android/guava/src/com/google/common/base/Function.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.common.base;
1616

1717
import com.google.common.annotations.GwtCompatible;
18+
import java.util.Objects;
1819
import org.jspecify.annotations.Nullable;
1920

2021
/**
@@ -50,8 +51,8 @@ public interface Function<F extends @Nullable Object, T extends @Nullable Object
5051
*
5152
* <ul>
5253
* <li>Its execution does not cause any observable side effects.
53-
* <li>The computation is <i>consistent with equals</i>; that is, {@link Objects#equal
54-
* Objects.equal}{@code (a, b)} implies that {@code Objects.equal(function.apply(a),
54+
* <li>The computation is <i>consistent with equals</i>; that is, {@link Objects#equals
55+
* Objects.equals}{@code (a, b)} implies that {@code Objects.equals(function.apply(a),
5556
* function.apply(b))}.
5657
* </ul>
5758
*

android/guava/src/com/google/common/base/Preconditions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,10 @@ private static String badElementIndex(int index, int size, String desc) {
13851385
* Ensures that {@code index} specifies a valid <i>position</i> in an array, list or string of
13861386
* size {@code size}. A position index may range from zero to {@code size}, inclusive.
13871387
*
1388+
* <p><b>Java 9 users:</b> consider using {@link java.util.Objects#checkIndex(index, size)}
1389+
* instead. However, note that {@code checkIndex()} throws {@code IndexOutOfBoundsException} when
1390+
* {@code size} is negative, while this method throws {@code IllegalArgumentException}.
1391+
*
13881392
* @param index a user-supplied index identifying a position in an array, list or string
13891393
* @param size the size of that array, list or string
13901394
* @return the value of {@code index}

android/guava/src/com/google/common/collect/HashBiMap.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.common.annotations.GwtCompatible;
2222
import com.google.common.annotations.GwtIncompatible;
2323
import com.google.common.annotations.J2ktIncompatible;
24-
import com.google.common.base.Objects;
2524
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2625
import com.google.errorprone.annotations.concurrent.LazyInit;
2726
import com.google.j2objc.annotations.RetainedWith;
@@ -36,6 +35,7 @@
3635
import java.util.Iterator;
3736
import java.util.Map;
3837
import java.util.NoSuchElementException;
38+
import java.util.Objects;
3939
import java.util.Set;
4040
import org.jspecify.annotations.Nullable;
4141

@@ -239,7 +239,7 @@ int findEntry(
239239
int[] nextInBucket,
240240
@Nullable Object[] array) {
241241
for (int entry = hashTable[bucket(oHash)]; entry != ABSENT; entry = nextInBucket[entry]) {
242-
if (Objects.equal(array[entry], o)) {
242+
if (Objects.equals(array[entry], o)) {
243243
return entry;
244244
}
245245
}
@@ -288,7 +288,7 @@ public boolean containsValue(@Nullable Object value) {
288288
int entryForKey = findEntryByKey(key, keyHash);
289289
if (entryForKey != ABSENT) {
290290
V oldValue = values[entryForKey];
291-
if (Objects.equal(oldValue, value)) {
291+
if (Objects.equals(oldValue, value)) {
292292
return value;
293293
} else {
294294
replaceValueInEntry(entryForKey, value, force);
@@ -332,7 +332,7 @@ public boolean containsValue(@Nullable Object value) {
332332
int entryForValue = findEntryByValue(value, valueHash);
333333
if (entryForValue != ABSENT) {
334334
K oldKey = keys[entryForValue];
335-
if (Objects.equal(oldKey, key)) {
335+
if (Objects.equals(oldKey, key)) {
336336
return key;
337337
} else {
338338
replaceKeyInEntry(entryForValue, key, force);
@@ -845,7 +845,7 @@ public boolean contains(@Nullable Object o) {
845845
Object k = e.getKey();
846846
Object v = e.getValue();
847847
int eIndex = findEntryByKey(k);
848-
return eIndex != ABSENT && Objects.equal(v, values[eIndex]);
848+
return eIndex != ABSENT && Objects.equals(v, values[eIndex]);
849849
}
850850
return false;
851851
}
@@ -859,7 +859,7 @@ public boolean remove(@Nullable Object o) {
859859
Object v = e.getValue();
860860
int kHash = Hashing.smearedHash(k);
861861
int eIndex = findEntryByKey(k, kHash);
862-
if (eIndex != ABSENT && Objects.equal(v, values[eIndex])) {
862+
if (eIndex != ABSENT && Objects.equals(v, values[eIndex])) {
863863
removeEntryKeyHashKnown(eIndex, kHash);
864864
return true;
865865
}
@@ -891,7 +891,7 @@ final class EntryForKey extends AbstractMapEntry<K, V> {
891891
}
892892

893893
void updateIndex() {
894-
if (index == ABSENT || index > size || !Objects.equal(keys[index], key)) {
894+
if (index == ABSENT || index > size || !Objects.equals(keys[index], key)) {
895895
index = findEntryByKey(key);
896896
}
897897
}
@@ -934,7 +934,7 @@ public V setValue(@ParametricNullness V value) {
934934
* position `index`.
935935
*/
936936
V oldValue = uncheckedCastNullableTToT(values[index]);
937-
if (Objects.equal(oldValue, value)) {
937+
if (Objects.equals(oldValue, value)) {
938938
return value;
939939
}
940940
replaceValueInEntry(index, value, false);
@@ -1044,7 +1044,7 @@ public boolean contains(@Nullable Object o) {
10441044
Object v = e.getKey();
10451045
Object k = e.getValue();
10461046
int eIndex = biMap.findEntryByValue(v);
1047-
return eIndex != ABSENT && Objects.equal(biMap.keys[eIndex], k);
1047+
return eIndex != ABSENT && Objects.equals(biMap.keys[eIndex], k);
10481048
}
10491049
return false;
10501050
}
@@ -1057,7 +1057,7 @@ public boolean remove(@Nullable Object o) {
10571057
Object k = e.getValue();
10581058
int vHash = Hashing.smearedHash(v);
10591059
int eIndex = biMap.findEntryByValue(v, vHash);
1060-
if (eIndex != ABSENT && Objects.equal(biMap.keys[eIndex], k)) {
1060+
if (eIndex != ABSENT && Objects.equals(biMap.keys[eIndex], k)) {
10611061
biMap.removeEntryValueHashKnown(eIndex, vHash);
10621062
return true;
10631063
}
@@ -1090,7 +1090,7 @@ static final class EntryForValue<K extends @Nullable Object, V extends @Nullable
10901090
}
10911091

10921092
private void updateIndex() {
1093-
if (index == ABSENT || index > biMap.size || !Objects.equal(value, biMap.values[index])) {
1093+
if (index == ABSENT || index > biMap.size || !Objects.equals(value, biMap.values[index])) {
10941094
index = biMap.findEntryByValue(value);
10951095
}
10961096
}
@@ -1118,7 +1118,7 @@ public K setValue(@ParametricNullness K key) {
11181118
return unsafeNull(); // see EntryForKey.setValue()
11191119
}
11201120
K oldKey = uncheckedCastNullableTToT(biMap.keys[index]); // see EntryForKey.setValue()
1121-
if (Objects.equal(oldKey, key)) {
1121+
if (Objects.equals(oldKey, key)) {
11221122
return key;
11231123
}
11241124
biMap.replaceKeyInEntry(index, key, false);

android/guava/src/com/google/common/collect/ObjectCountHashMap.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
import com.google.common.annotations.GwtCompatible;
2424
import com.google.common.annotations.VisibleForTesting;
25-
import com.google.common.base.Objects;
2625
import com.google.common.base.Preconditions;
2726
import com.google.common.collect.Multiset.Entry;
2827
import com.google.common.collect.Multisets.AbstractEntry;
2928
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3029
import java.util.Arrays;
30+
import java.util.Objects;
3131
import org.jspecify.annotations.NullMarked;
3232
import org.jspecify.annotations.Nullable;
3333

@@ -228,7 +228,7 @@ public K getElement() {
228228
void updateLastKnownIndex() {
229229
if (lastKnownIndex == -1
230230
|| lastKnownIndex >= size()
231-
|| !Objects.equal(key, keys[lastKnownIndex])) {
231+
|| !Objects.equals(key, keys[lastKnownIndex])) {
232232
lastKnownIndex = indexOf(key);
233233
}
234234
}
@@ -298,7 +298,7 @@ public int put(@ParametricNullness K key, int value) {
298298
do {
299299
last = next;
300300
entry = entries[next];
301-
if (getHash(entry) == hash && Objects.equal(key, keys[next])) {
301+
if (getHash(entry) == hash && Objects.equals(key, keys[next])) {
302302
int oldValue = values[next];
303303

304304
values[next] = value;
@@ -391,7 +391,7 @@ int indexOf(@Nullable Object key) {
391391
int next = table[hash & hashTableMask()];
392392
while (next != UNSET) {
393393
long entry = entries[next];
394-
if (getHash(entry) == hash && Objects.equal(key, keys[next])) {
394+
if (getHash(entry) == hash && Objects.equals(key, keys[next])) {
395395
return next;
396396
}
397397
next = getNext(entry);
@@ -422,7 +422,7 @@ private int remove(@Nullable Object key, int hash) {
422422
int last = UNSET;
423423
do {
424424
if (getHash(entries[next]) == hash) {
425-
if (Objects.equal(key, keys[next])) {
425+
if (Objects.equals(key, keys[next])) {
426426
int oldValue = values[next];
427427

428428
if (last == UNSET) {

android/guava/src/com/google/common/graph/Graphs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static java.util.Objects.requireNonNull;
2222

2323
import com.google.common.annotations.Beta;
24-
import com.google.common.base.Objects;
2524
import com.google.common.collect.ImmutableSet;
2625
import com.google.common.collect.Iterables;
2726
import com.google.common.collect.Iterators;
@@ -33,6 +32,7 @@
3332
import java.util.HashSet;
3433
import java.util.Iterator;
3534
import java.util.Map;
35+
import java.util.Objects;
3636
import java.util.Queue;
3737
import java.util.Set;
3838
import org.jspecify.annotations.Nullable;
@@ -165,7 +165,7 @@ private static final class NodeAndRemainingSuccessors<N> {
165165
*/
166166
private static boolean canTraverseWithoutReusingEdge(
167167
Graph<?> graph, Object nextNode, @Nullable Object previousNode) {
168-
if (graph.isDirected() || !Objects.equal(previousNode, nextNode)) {
168+
if (graph.isDirected() || !Objects.equals(previousNode, nextNode)) {
169169
return true;
170170
}
171171
// This falls into the undirected A->B->A case. The Graph interface does not support parallel

guava-testlib/src/com/google/common/testing/ClassSanityTester.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.common.annotations.J2ktIncompatible;
2626
import com.google.common.annotations.VisibleForTesting;
2727
import com.google.common.base.Joiner;
28-
import com.google.common.base.Objects;
2928
import com.google.common.collect.ArrayListMultimap;
3029
import com.google.common.collect.ImmutableList;
3130
import com.google.common.collect.ListMultimap;
@@ -50,6 +49,7 @@
5049
import java.util.HashSet;
5150
import java.util.List;
5251
import java.util.Map.Entry;
52+
import java.util.Objects;
5353
import java.util.Set;
5454
import junit.framework.Assert;
5555
import junit.framework.AssertionFailedError;
@@ -164,7 +164,7 @@ public <T> ClassSanityTester setDistinctValues(Class<T> type, T value1, T value2
164164
checkNotNull(type);
165165
checkNotNull(value1);
166166
checkNotNull(value2);
167-
checkArgument(!Objects.equal(value1, value2), "Duplicate value provided.");
167+
checkArgument(!Objects.equals(value1, value2), "Duplicate value provided.");
168168
distinctValues.replaceValues(type, ImmutableList.of(value1, value2));
169169
setDefault(type, value1);
170170
return this;
@@ -607,7 +607,7 @@ String reportItem(Item<?> item) {
607607
List<Object> newArgs = new ArrayList<>(args);
608608
Object newArg = argGenerators.get(i).generateFresh(params.get(i).getType());
609609

610-
if (newArg == null || Objects.equal(args.get(i), newArg)) {
610+
if (newArg == null || Objects.equals(args.get(i), newArg)) {
611611
if (params.get(i).getType().getRawType().isEnum()) {
612612
continue; // Nothing better we can do if it's single-value enum
613613
}
@@ -638,7 +638,7 @@ private List<Object> generateEqualFactoryArguments(
638638
// Two newFreshValueGenerator() instances should normally generate equal value sequence.
639639
Object shouldBeEqualArg = generateDummyArg(param, newFreshValueGenerator());
640640
if (arg != shouldBeEqualArg
641-
&& Objects.equal(arg, shouldBeEqualArg)
641+
&& Objects.equals(arg, shouldBeEqualArg)
642642
&& hashCodeInsensitiveToArgReference(factory, args, i, shouldBeEqualArg)
643643
&& hashCodeInsensitiveToArgReference(
644644
factory, args, i, generateDummyArg(param, newFreshValueGenerator()))) {

guava/src/com/google/common/base/Equivalence.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.errorprone.annotations.ForOverride;
2323
import com.google.errorprone.annotations.InlineMe;
2424
import java.io.Serializable;
25+
import java.util.Objects;
2526
import java.util.function.BiPredicate;
2627
import org.jspecify.annotations.NonNull;
2728
import org.jspecify.annotations.Nullable;
@@ -331,14 +332,14 @@ public boolean equals(@Nullable Object obj) {
331332
}
332333
if (obj instanceof EquivalentToPredicate) {
333334
EquivalentToPredicate<?> that = (EquivalentToPredicate<?>) obj;
334-
return equivalence.equals(that.equivalence) && Objects.equal(target, that.target);
335+
return equivalence.equals(that.equivalence) && Objects.equals(target, that.target);
335336
}
336337
return false;
337338
}
338339

339340
@Override
340341
public int hashCode() {
341-
return Objects.hashCode(equivalence, target);
342+
return Objects.hash(equivalence, target);
342343
}
343344

344345
@Override

guava/src/com/google/common/base/Preconditions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,10 @@ private static String badElementIndex(int index, int size, String desc) {
13851385
* Ensures that {@code index} specifies a valid <i>position</i> in an array, list or string of
13861386
* size {@code size}. A position index may range from zero to {@code size}, inclusive.
13871387
*
1388+
* <p><b>Java 9 users:</b> consider using {@link java.util.Objects#checkIndex(index, size)}
1389+
* instead. However, note that {@code checkIndex()} throws {@code IndexOutOfBoundsException} when
1390+
* {@code size} is negative, while this method throws {@code IllegalArgumentException}.
1391+
*
13881392
* @param index a user-supplied index identifying a position in an array, list or string
13891393
* @param size the size of that array, list or string
13901394
* @return the value of {@code index}

0 commit comments

Comments
 (0)