Skip to content

Commit 7b9366e

Browse files
Vincent PotucekGoogle Java Core Libraries
authored andcommitted
Apply UnnecessaryParentheses.
And sneak in a few other simplifications, mostly to remove explicit type arguments. Fixes #7930 RELNOTES=n/a PiperOrigin-RevId: 793754837
1 parent 7e91dd2 commit 7b9366e

File tree

74 files changed

+162
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+162
-165
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ public void testEntrySetRetainAll() {
687687
Set<Entry<K, V>> entriesToRetain =
688688
singleton(mapEntry(originalEntry.getKey(), originalEntry.getValue()));
689689
if (supportsRemove) {
690-
boolean shouldRemove = (entrySet.size() > entriesToRetain.size());
690+
boolean shouldRemove = entrySet.size() > entriesToRetain.size();
691691
boolean didRemove = entrySet.retainAll(entriesToRetain);
692692
assertEquals(shouldRemove, didRemove);
693693
assertEquals(entriesToRetain.size(), map.size());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private TestSuite createReserializedSuite(SortedMultisetTestSuiteBuilder<E> pare
274274
new ForwardingTestMultisetGenerator<E>(delegate) {
275275
@Override
276276
public SortedMultiset<E> create(Object... entries) {
277-
return SerializableTester.reserialize(((SortedMultiset<E>) super.create(entries)));
277+
return SerializableTester.reserialize((SortedMultiset<E>) super.create(entries));
278278
}
279279
})
280280
.named(parentBuilder.getName() + " reserialized")

android/guava-testlib/src/com/google/common/collect/testing/testers/SetHashCodeTester.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class SetHashCodeTester<E> extends AbstractSetTester<E> {
4141
public void testHashCode() {
4242
int expectedHashCode = 0;
4343
for (E element : getSampleElements()) {
44-
expectedHashCode += ((element == null) ? 0 : element.hashCode());
44+
expectedHashCode += (element == null) ? 0 : element.hashCode();
4545
}
4646
assertEquals(
4747
"A Set's hashCode() should be the sum of those of its elements.",
@@ -55,7 +55,7 @@ public void testHashCode_containingNull() {
5555
Collection<E> elements = getSampleElements(getNumElements() - 1);
5656
int expectedHashCode = 0;
5757
for (E element : elements) {
58-
expectedHashCode += ((element == null) ? 0 : element.hashCode());
58+
expectedHashCode += (element == null) ? 0 : element.hashCode();
5959
}
6060

6161
elements.add(null);

android/guava-tests/benchmark/com/google/common/base/StopwatchBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ long manual(int reps) {
4646
for (int i = 0; i < reps; i++) {
4747
long start = System.nanoTime();
4848
// here is where you would do something
49-
total += (System.nanoTime() - start);
49+
total += System.nanoTime() - start;
5050
}
5151
return total;
5252
}

android/guava-tests/benchmark/com/google/common/hash/HashCodeBenchmark.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ boolean doEquals(byte[] a, byte[] b) {
7070
}
7171
boolean areEqual = true;
7272
for (int i = 0; i < a.length; i++) {
73-
areEqual &= (a[i] == b[i]);
73+
areEqual &= a[i] == b[i];
7474
}
7575
return areEqual;
7676
}
@@ -85,7 +85,7 @@ boolean doEquals(byte[] a, byte[] b) {
8585
for (int i = 0; i < a.length; i++) {
8686
result = (byte) (result | a[i] ^ b[i]);
8787
}
88-
return (result == 0);
88+
return result == 0;
8989
}
9090
},
9191
XORING_TO_INT {
@@ -98,7 +98,7 @@ boolean doEquals(byte[] a, byte[] b) {
9898
for (int i = 0; i < a.length; i++) {
9999
result |= a[i] ^ b[i];
100100
}
101-
return (result == 0);
101+
return result == 0;
102102
}
103103
},
104104
MESSAGE_DIGEST_IS_EQUAL {

android/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class MonitorBenchmark {
4646
@SuppressWarnings("unchecked")
4747
void setUp() throws Exception {
4848
String prefix =
49-
(useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.");
49+
useMonitor ? "com.google.common.util.concurrent.MonitorBased" : "java.util.concurrent.";
5050
String className = prefix + queueType + "BlockingQueue";
5151
Constructor<?> constructor = Class.forName(className).getConstructor(int.class);
5252
queue = (BlockingQueue<String>) constructor.newInstance(capacity);

android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ public String load(String key) throws InterruptedException {
19411941
// doConcurrentGet alternates between calling getUnchecked and calling get, but an unchecked
19421942
// exception thrown by the loader is always wrapped as an UncheckedExecutionException.
19431943
assertThat(result.get(i)).isInstanceOf(UncheckedExecutionException.class);
1944-
assertThat(((UncheckedExecutionException) result.get(i))).hasCauseThat().isSameInstanceAs(e);
1944+
assertThat((UncheckedExecutionException) result.get(i)).hasCauseThat().isSameInstanceAs(e);
19451945
}
19461946

19471947
// subsequent calls should call the loader again, not get the old exception

android/guava-tests/test/com/google/common/cache/CacheTesting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static <K, V> LocalCache<K, V> toLocalCache(Cache<K, V> cache) {
128128
* without throwing an exception.
129129
*/
130130
static boolean hasLocalCache(Cache<?, ?> cache) {
131-
return (checkNotNull(cache) instanceof LocalLoadingCache);
131+
return checkNotNull(cache) instanceof LocalLoadingCache;
132132
}
133133

134134
static void drainRecencyQueues(Cache<?, ?> cache) {

android/guava-tests/test/com/google/common/cache/LocalCacheTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ public int hashCode() {
30553055

30563056
@Override
30573057
public boolean equals(@Nullable Object o) {
3058-
return (o instanceof SerializableCacheLoader);
3058+
return o instanceof SerializableCacheLoader;
30593059
}
30603060
}
30613061

@@ -3071,7 +3071,7 @@ public int hashCode() {
30713071

30723072
@Override
30733073
public boolean equals(@Nullable Object o) {
3074-
return (o instanceof SerializableRemovalListener);
3074+
return o instanceof SerializableRemovalListener;
30753075
}
30763076
}
30773077

@@ -3088,7 +3088,7 @@ public int hashCode() {
30883088

30893089
@Override
30903090
public boolean equals(@Nullable Object o) {
3091-
return (o instanceof SerializableTicker);
3091+
return o instanceof SerializableTicker;
30923092
}
30933093
}
30943094

@@ -3105,7 +3105,7 @@ public int hashCode() {
31053105

31063106
@Override
31073107
public boolean equals(@Nullable Object o) {
3108-
return (o instanceof SerializableWeigher);
3108+
return o instanceof SerializableWeigher;
31093109
}
31103110
}
31113111
}

android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetBasherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ public int[] call() throws Exception {
138138
{
139139
int newValue = random.nextInt(3);
140140
int oldValue = multiset.setCount(key, newValue);
141-
deltas[keyIndex] += (newValue - oldValue);
141+
deltas[keyIndex] += newValue - oldValue;
142142
break;
143143
}
144144
case SET_COUNT_IF:
145145
{
146146
int newValue = random.nextInt(3);
147147
int oldValue = multiset.count(key);
148148
if (multiset.setCount(key, oldValue, newValue)) {
149-
deltas[keyIndex] += (newValue - oldValue);
149+
deltas[keyIndex] += newValue - oldValue;
150150
}
151151
break;
152152
}

0 commit comments

Comments
 (0)