Skip to content

Commit 3a8463a

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Use some static imports.
RELNOTES=n/a PiperOrigin-RevId: 687404334
1 parent dc12fb2 commit 3a8463a

File tree

70 files changed

+252
-171
lines changed

Some content is hidden

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

70 files changed

+252
-171
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.common.collect.testing;
1818

19+
import static java.lang.Math.max;
1920
import static java.util.Collections.sort;
2021
import static junit.framework.Assert.assertEquals;
2122
import static junit.framework.Assert.assertFalse;
@@ -365,7 +366,7 @@ public static <T extends Comparable<? super T>> void testCompareToAndEquals(
365366

366367
@Override
367368
public int size() {
368-
return Math.max(0, data.size() + delta);
369+
return max(0, data.size() + delta);
369370
}
370371

371372
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS;
2222
import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEY_QUERIES;
2323
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
24+
import static java.lang.Math.max;
2425

2526
import com.google.common.annotations.GwtCompatible;
2627
import com.google.common.collect.Multimap;
@@ -83,7 +84,7 @@ public void testKeysElementSet() {
8384
@MapFeature.Require(SUPPORTS_REMOVE)
8485
public void testKeysRemove() {
8586
int original = multimap().keys().remove(k0(), 1);
86-
assertEquals(Math.max(original - 1, 0), multimap().get(k0()).size());
87+
assertEquals(max(original - 1, 0), multimap().get(k0()).size());
8788
}
8889

8990
@CollectionSize.Require(ONE)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static com.google.common.collect.testing.SampleElements.Strings.AFTER_LAST_2;
2424
import static com.google.common.collect.testing.SampleElements.Strings.BEFORE_FIRST;
2525
import static com.google.common.collect.testing.SampleElements.Strings.BEFORE_FIRST_2;
26+
import static java.lang.Math.max;
2627
import static junit.framework.Assert.assertEquals;
2728

2829
import com.google.common.annotations.GwtCompatible;
@@ -108,7 +109,7 @@ public static class ImmutableSetTooSmallBuilderGenerator extends TestStringSetGe
108109
@Override
109110
protected Set<String> create(String[] elements) {
110111
ImmutableSet.Builder<String> builder =
111-
ImmutableSet.builderWithExpectedSize(Math.max(0, Sets.newHashSet(elements).size() - 1));
112+
ImmutableSet.builderWithExpectedSize(max(0, Sets.newHashSet(elements).size() - 1));
112113
for (String e : elements) {
113114
builder.add(e);
114115
}

android/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.common.collect;
1818

19+
import static java.lang.Math.min;
20+
1921
import com.google.caliper.BeforeExperiment;
2022
import com.google.caliper.Benchmark;
2123
import com.google.caliper.Param;
@@ -51,7 +53,7 @@ void setUp() {
5153
while (sizeRemaining > 0) {
5254
// The JVM will return interned values for small ints.
5355
Integer value = random.nextInt(1000) + 128;
54-
int count = Math.min(random.nextInt(10) + 1, sizeRemaining);
56+
int count = min(random.nextInt(10) + 1, sizeRemaining);
5557
sizeRemaining -= count;
5658
hashMultiset.add(value, count);
5759
linkedHashMultiset.add(value, count);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.collect.Iterables.getOnlyElement;
2020
import static com.google.common.truth.Truth.assertThat;
21+
import static java.lang.Math.max;
2122

2223
import com.google.common.collect.testing.MapTestSuiteBuilder;
2324
import com.google.common.collect.testing.TestStringMapGenerator;
@@ -111,7 +112,7 @@ public void testAllocArraysExpectedSize() {
111112

112113
map.put(1, "1");
113114
assertThat(map.needsAllocArrays()).isFalse();
114-
int expectedSize = Math.max(1, i);
115+
int expectedSize = max(1, i);
115116
assertThat(map.entries).hasLength(expectedSize);
116117
assertThat(map.keys).hasLength(expectedSize);
117118
assertThat(map.values).hasLength(expectedSize);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.google.common.collect;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20-
import static java.util.stream.Collectors.*;
20+
import static java.lang.Math.max;
2121

2222
import com.google.common.annotations.GwtIncompatible;
2323
import com.google.common.collect.testing.SetTestSuiteBuilder;
@@ -104,7 +104,7 @@ public void testAllocArraysExpectedSize() {
104104

105105
set.add(1);
106106
assertThat(set.needsAllocArrays()).isFalse();
107-
int expectedSize = Math.max(1, i);
107+
int expectedSize = max(1, i);
108108
assertThat(set.elements).hasLength(expectedSize);
109109
}
110110
}

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

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

1717
import static com.google.common.truth.Truth.assertThat;
18+
import static java.lang.Math.max;
1819

1920
import com.google.common.collect.testing.MapTestSuiteBuilder;
2021
import com.google.common.collect.testing.TestStringMapGenerator;
@@ -170,7 +171,7 @@ public void testAllocArraysExpectedSize() {
170171

171172
map.put(1, Integer.toString(1));
172173
assertThat(map.needsAllocArrays()).isFalse();
173-
int expectedSize = Math.max(1, i);
174+
int expectedSize = max(1, i);
174175
assertThat(map.entries).hasLength(expectedSize);
175176
assertThat(map.keys).hasLength(expectedSize);
176177
assertThat(map.values).hasLength(expectedSize);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.collect;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20+
import static java.lang.Math.max;
2021

2122
import com.google.common.annotations.GwtIncompatible;
2223
import com.google.common.collect.testing.SetTestSuiteBuilder;
@@ -85,7 +86,7 @@ public void testAllocArraysExpectedSize() {
8586

8687
set.add(1);
8788
assertThat(set.needsAllocArrays()).isFalse();
88-
int expectedSize = Math.max(1, i);
89+
int expectedSize = max(1, i);
8990
assertThat(set.elements).hasLength(expectedSize);
9091
}
9192
}

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.common.collect;
1818

19+
import static com.google.common.collect.Comparators.max;
20+
import static com.google.common.collect.Comparators.min;
1921
import static com.google.common.truth.Truth.assertThat;
2022
import static java.util.Arrays.asList;
2123

@@ -75,26 +77,26 @@ public void testIsInStrictOrder() {
7577
}
7678

7779
public void testMinMaxNatural() {
78-
assertThat(Comparators.min(1, 2)).isEqualTo(1);
79-
assertThat(Comparators.min(2, 1)).isEqualTo(1);
80-
assertThat(Comparators.max(1, 2)).isEqualTo(2);
81-
assertThat(Comparators.max(2, 1)).isEqualTo(2);
80+
assertThat(min(1, 2)).isEqualTo(1);
81+
assertThat(min(2, 1)).isEqualTo(1);
82+
assertThat(max(1, 2)).isEqualTo(2);
83+
assertThat(max(2, 1)).isEqualTo(2);
8284
}
8385

8486
public void testMinMaxNatural_equalInstances() {
8587
Foo a = new Foo(1);
8688
Foo b = new Foo(1);
87-
assertThat(Comparators.min(a, b)).isSameInstanceAs(a);
88-
assertThat(Comparators.max(a, b)).isSameInstanceAs(a);
89+
assertThat(min(a, b)).isSameInstanceAs(a);
90+
assertThat(max(a, b)).isSameInstanceAs(a);
8991
}
9092

9193
public void testMinMaxComparator() {
9294
Comparator<Integer> natural = Ordering.natural();
9395
Comparator<Integer> reverse = Collections.reverseOrder(natural);
94-
assertThat(Comparators.min(1, 2, reverse)).isEqualTo(2);
95-
assertThat(Comparators.min(2, 1, reverse)).isEqualTo(2);
96-
assertThat(Comparators.max(1, 2, reverse)).isEqualTo(1);
97-
assertThat(Comparators.max(2, 1, reverse)).isEqualTo(1);
96+
assertThat(min(1, 2, reverse)).isEqualTo(2);
97+
assertThat(min(2, 1, reverse)).isEqualTo(2);
98+
assertThat(max(1, 2, reverse)).isEqualTo(1);
99+
assertThat(max(2, 1, reverse)).isEqualTo(1);
98100
}
99101

100102
/**
@@ -113,8 +115,8 @@ public int compare(Number a, Number b) {
113115
Integer comparand1 = 1;
114116
Integer comparand2 = 2;
115117

116-
Integer min = Comparators.min(comparand1, comparand2, numberComparator);
117-
Integer max = Comparators.max(comparand1, comparand2, numberComparator);
118+
Integer min = min(comparand1, comparand2, numberComparator);
119+
Integer max = max(comparand1, comparand2, numberComparator);
118120

119121
assertThat(min).isEqualTo(1);
120122
assertThat(max).isEqualTo(2);
@@ -125,8 +127,8 @@ public void testMinMaxComparator_equalInstances() {
125127
Comparator<Foo> reverse = Collections.reverseOrder(natural);
126128
Foo a = new Foo(1);
127129
Foo b = new Foo(1);
128-
assertThat(Comparators.min(a, b, reverse)).isSameInstanceAs(a);
129-
assertThat(Comparators.max(a, b, reverse)).isSameInstanceAs(a);
130+
assertThat(min(a, b, reverse)).isSameInstanceAs(a);
131+
assertThat(max(a, b, reverse)).isSameInstanceAs(a);
130132
}
131133

132134
private static class Foo implements Comparable<Foo> {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.common.collect;
1818

19+
import static java.lang.Math.min;
20+
1921
import com.google.common.base.Function;
2022
import com.google.common.primitives.Ints;
2123
import java.util.List;
@@ -148,7 +150,7 @@ public int[] call() throws Exception {
148150
{
149151
int delta = random.nextInt(6); // [0, 5]
150152
int oldValue = multiset.remove(key, delta);
151-
deltas[keyIndex] -= Math.min(delta, oldValue);
153+
deltas[keyIndex] -= min(delta, oldValue);
152154
break;
153155
}
154156
case REMOVE_EXACTLY:

0 commit comments

Comments
 (0)