Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 728791732
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Feb 19, 2025
1 parent 7d73105 commit c4965e4
Show file tree
Hide file tree
Showing 103 changed files with 482 additions and 522 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private void compareResultsForThisListOfStimuli() {
}

private static List<Object> subListCopy(Object[] source, int size) {
final Object[] copy = new Object[size];
Object[] copy = new Object[size];
arraycopy(source, 0, copy, 0, size);
return asList(copy);
}
Expand Down Expand Up @@ -479,7 +479,7 @@ private <T extends Iterator<E>> void internalExecuteAndCompare(
};

private final IteratorOperation newAddMethod() {
final Object toInsert = elementsToInsert.next();
Object toInsert = elementsToInsert.next();
return new IteratorOperation() {
@Override
public @Nullable Object execute(Iterator<?> iterator) {
Expand All @@ -492,7 +492,7 @@ private final IteratorOperation newAddMethod() {
}

private final IteratorOperation newSetMethod() {
final E toInsert = elementsToInsert.next();
E toInsert = elementsToInsert.next();
return new IteratorOperation() {
@Override
public @Nullable Object execute(Iterator<?> iterator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public Test testsForAbstractList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(final String[] elements) {
protected List<String> create(String[] elements) {
return new AbstractList<String>() {
@Override
public int size() {
Expand All @@ -300,9 +300,9 @@ public Test testsForAbstractSequentialList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(final String[] elements) {
protected List<String> create(String[] elements) {
// For this test we trust ArrayList works
final List<String> list = new ArrayList<>();
List<String> list = new ArrayList<>();
Collections.addAll(list, elements);
return new AbstractSequentialList<String>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public Test testsForAbstractSet() {
new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
final String[] deduped = dedupe(elements);
String[] deduped = dedupe(elements);
return new AbstractSet<String>() {
@Override
public int size() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private static <T> void setImplementation(Class<T> type, Class<? extends T> impl
if (Modifier.isAbstract(type.getModifiers()) || !Modifier.isPublic(type.getModifiers())) {
return arbitraryConstantInstanceOrNull(type);
}
final Constructor<T> constructor;
Constructor<T> constructor;
try {
constructor = type.getConstructor();
} catch (NoSuchMethodException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public FactoryMethodReturnValueTester testEqualsAndSerializable() throws Excepti
}
}

private void testEqualsUsing(final Invokable<?, ?> factory)
private void testEqualsUsing(Invokable<?, ?> factory)
throws ParameterNotInstantiableException,
ParameterHasNoDistinctValueException,
IllegalAccessException,
Expand All @@ -587,7 +587,7 @@ private void testEqualsUsing(final Invokable<?, ?> factory)
Object instance = createInstance(factory, args);
List<Object> equalArgs = generateEqualFactoryArguments(factory, params, args);
// Each group is a List of items, each item has a list of factory args.
final List<List<List<Object>>> argGroups = Lists.newArrayList();
List<List<List<Object>>> argGroups = Lists.newArrayList();
argGroups.add(ImmutableList.of(args, equalArgs));
EqualsTester tester =
new EqualsTester(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ final <T> void addSampleInstances(Class<T> type, Iterable<? extends T> instances
return Primitives.wrap(type).cast(generateFresh(TypeToken.of(type)));
}

final <T> T newFreshProxy(final Class<T> interfaceType) {
final <T> T newFreshProxy(Class<T> interfaceType) {
T proxy = newProxy(interfaceType);
freshness.incrementAndGet();
return proxy;
Expand Down Expand Up @@ -268,7 +268,7 @@ final <T> T newFreshProxy(final Class<T> interfaceType) {
return ArbitraryInstances.get(rawType);
}

private <T> T newProxy(final Class<T> interfaceType) {
private <T> T newProxy(Class<T> interfaceType) {
return Reflection.newProxy(interfaceType, new FreshInvocationHandler(interfaceType));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ private void testParameter(
}

private <F, T> Converter<F, T> defaultConverter(
final TypeToken<F> convertFromType, final TypeToken<T> convertToType) {
TypeToken<F> convertFromType, TypeToken<T> convertToType) {
return new Converter<F, T>() {
@Override
protected T doForward(F a) {
Expand All @@ -477,7 +477,7 @@ private static TypeToken<?> getFirstTypeParameter(Type type) {
}
}

private <T> T newDefaultReturningProxy(final TypeToken<T> type) {
private <T> T newDefaultReturningProxy(TypeToken<T> type) {
return new DummyProxy() {
@Override
<R> @Nullable R dummyReturnValue(TypeToken<R> returnType) {
Expand Down
14 changes: 7 additions & 7 deletions android/guava/src/com/google/common/base/CharMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static CharMatcher singleWidth() {
// Static factories

/** Returns a {@code char} matcher that matches only one specified BMP character. */
public static CharMatcher is(final char match) {
public static CharMatcher is(char match) {
return new Is(match);
}

Expand All @@ -303,15 +303,15 @@ public static CharMatcher is(final char match) {
*
* <p>To negate another {@code CharMatcher}, use {@link #negate()}.
*/
public static CharMatcher isNot(final char match) {
public static CharMatcher isNot(char match) {
return new IsNot(match);
}

/**
* Returns a {@code char} matcher that matches any BMP character present in the given character
* sequence. Returns a bogus matcher if the sequence contains supplementary characters.
*/
public static CharMatcher anyOf(final CharSequence sequence) {
public static CharMatcher anyOf(CharSequence sequence) {
switch (sequence.length()) {
case 0:
return none();
Expand Down Expand Up @@ -341,15 +341,15 @@ public static CharMatcher noneOf(CharSequence sequence) {
*
* @throws IllegalArgumentException if {@code endInclusive < startInclusive}
*/
public static CharMatcher inRange(final char startInclusive, final char endInclusive) {
public static CharMatcher inRange(char startInclusive, char endInclusive) {
return new InRange(startInclusive, endInclusive);
}

/**
* Returns a matcher with identical behavior to the given {@link Character}-based predicate, but
* which operates on primitive {@code char} instances instead.
*/
public static CharMatcher forPredicate(final Predicate<? super Character> predicate) {
public static CharMatcher forPredicate(Predicate<? super Character> predicate) {
return predicate instanceof CharMatcher ? (CharMatcher) predicate : new ForPredicate(predicate);
}

Expand Down Expand Up @@ -416,7 +416,7 @@ public CharMatcher precomputed() {
*/
@GwtIncompatible // SmallCharMatcher
CharMatcher precomputedInternal() {
final BitSet table = new BitSet();
BitSet table = new BitSet();
setBits(table);
int totalCharacters = table.cardinality();
if (totalCharacters * 2 <= DISTINCT_CHARS) {
Expand All @@ -426,7 +426,7 @@ CharMatcher precomputedInternal() {
table.flip(Character.MIN_VALUE, Character.MAX_VALUE + 1);
int negatedCharacters = DISTINCT_CHARS - totalCharacters;
String suffix = ".negate()";
final String description = toString();
String description = toString();
String negatedDescription =
description.endsWith(suffix)
? description.substring(0, description.length() - suffix.length())
Expand Down
2 changes: 1 addition & 1 deletion android/guava/src/com/google/common/base/Optional.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public java.util.Optional<T> toJavaUtil() {
* @since 11.0 (generics widened in 13.0)
*/
public static <T> Iterable<T> presentInstances(
final Iterable<? extends Optional<? extends T>> optionals) {
Iterable<? extends Optional<? extends T>> optionals) {
checkNotNull(optionals);
return () ->
new AbstractIterator<T>() {
Expand Down
12 changes: 6 additions & 6 deletions android/guava/src/com/google/common/base/Splitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static Splitter on(char separator) {
* separator
* @return a splitter, with default settings, that uses this matcher
*/
public static Splitter on(final CharMatcher separatorMatcher) {
public static Splitter on(CharMatcher separatorMatcher) {
checkNotNull(separatorMatcher);

return new Splitter(
Expand All @@ -163,7 +163,7 @@ int separatorEnd(int separatorPosition) {
* @param separator the literal, nonempty string to recognize as a separator
* @return a splitter, with default settings, that recognizes that separator
*/
public static Splitter on(final String separator) {
public static Splitter on(String separator) {
checkArgument(separator.length() != 0, "The separator may not be the empty string.");
if (separator.length() == 1) {
return Splitter.on(separator.charAt(0));
Expand Down Expand Up @@ -210,15 +210,15 @@ public static Splitter on(Pattern separatorPattern) {
}

/** Internal utility; see {@link #on(Pattern)} instead. */
static Splitter onPatternInternal(final CommonPattern separatorPattern) {
static Splitter onPatternInternal(CommonPattern separatorPattern) {
checkArgument(
!separatorPattern.matcher("").matches(),
"The pattern may not match the empty string: %s",
separatorPattern);

return new Splitter(
(splitter, toSplit) -> {
final CommonMatcher matcher = separatorPattern.matcher(toSplit);
CommonMatcher matcher = separatorPattern.matcher(toSplit);
return new SplittingIterator(splitter, toSplit) {
@Override
public int separatorStart(int start) {
Expand Down Expand Up @@ -268,7 +268,7 @@ public static Splitter onPattern(String separatorPattern) {
* @return a splitter, with default settings, that can split into fixed sized pieces
* @throws IllegalArgumentException if {@code length} is zero or negative
*/
public static Splitter fixedLength(final int length) {
public static Splitter fixedLength(int length) {
checkArgument(length > 0, "The length may not be less than 1");

return new Splitter(
Expand Down Expand Up @@ -365,7 +365,7 @@ public Splitter trimResults(CharMatcher trimmer) {
* @param sequence the sequence of characters to split
* @return an iteration over the segments split from the parameter
*/
public Iterable<String> split(final CharSequence sequence) {
public Iterable<String> split(CharSequence sequence) {
checkNotNull(sequence);

return new Iterable<String>() {
Expand Down
8 changes: 4 additions & 4 deletions android/guava/src/com/google/common/base/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ public static String repeat(String string, int count) {
}

// IF YOU MODIFY THE CODE HERE, you must update StringsRepeatBenchmark
final int len = string.length();
final long longSize = (long) len * (long) count;
final int size = (int) longSize;
int len = string.length();
long longSize = (long) len * (long) count;
int size = (int) longSize;
if (size != longSize) {
throw new ArrayIndexOutOfBoundsException("Required array size too large: " + longSize);
}

final char[] array = new char[size];
char[] array = new char[size];
string.getChars(0, len, array, 0);
int n;
for (n = len; n < size - n; n <<= 1) {
Expand Down
4 changes: 2 additions & 2 deletions android/guava/src/com/google/common/cache/CacheLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public V load(K key) {
*/
@GwtIncompatible // Executor + Futures
public static <K, V> CacheLoader<K, V> asyncReloading(
final CacheLoader<K, V> loader, final Executor executor) {
CacheLoader<K, V> loader, Executor executor) {
checkNotNull(loader);
checkNotNull(executor);
return new CacheLoader<K, V>() {
Expand All @@ -194,7 +194,7 @@ public V load(K key) throws Exception {
}

@Override
public ListenableFuture<V> reload(final K key, final V oldValue) {
public ListenableFuture<V> reload(K key, V oldValue) {
ListenableFutureTask<V> task =
ListenableFutureTask.create(() -> loader.reload(key, oldValue).get());
executor.execute(task);
Expand Down
16 changes: 8 additions & 8 deletions android/guava/src/com/google/common/cache/LocalCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -2217,11 +2217,11 @@ V loadSync(
}

ListenableFuture<V> loadAsync(
final K key,
final int hash,
final LoadingValueReference<K, V> loadingValueReference,
K key,
int hash,
LoadingValueReference<K, V> loadingValueReference,
CacheLoader<? super K, V> loader) {
final ListenableFuture<V> loadingFuture = loadingValueReference.loadFuture(key, loader);
ListenableFuture<V> loadingFuture = loadingValueReference.loadFuture(key, loader);
loadingFuture.addListener(
() -> {
try {
Expand Down Expand Up @@ -2286,7 +2286,7 @@ V scheduleRefresh(
*/
@CanIgnoreReturnValue
@Nullable V refresh(K key, int hash, CacheLoader<? super K, V> loader, boolean checkTime) {
final LoadingValueReference<K, V> loadingValueReference =
LoadingValueReference<K, V> loadingValueReference =
insertLoadingValueReference(key, hash, checkTime);
if (loadingValueReference == null) {
return null;
Expand All @@ -2308,7 +2308,7 @@ V scheduleRefresh(
* is already loading.
*/
@Nullable LoadingValueReference<K, V> insertLoadingValueReference(
final K key, final int hash, boolean checkTime) {
K key, int hash, boolean checkTime) {
ReferenceEntry<K, V> e = null;
lock();
try {
Expand Down Expand Up @@ -4065,7 +4065,7 @@ public boolean containsValue(@Nullable Object value) {
// in time it was present somewhere int the map. This becomes increasingly unlikely as
// CONTAINS_VALUE_RETRIES increases, though without locking it is theoretically possible.
long now = ticker.read();
final Segment<K, V>[] segments = this.segments;
Segment<K, V>[] segments = this.segments;
long last = -1L;
for (int i = 0; i < CONTAINS_VALUE_RETRIES; i++) {
long sum = 0L;
Expand Down Expand Up @@ -4674,7 +4674,7 @@ private LocalManualCache(LocalCache<K, V> localCache) {
}

@Override
public V get(K key, final Callable<? extends V> valueLoader) throws ExecutionException {
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
checkNotNull(valueLoader);
return localCache.get(
key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public V setValue(V value) {
}

Iterator<Entry<K, V>> entrySetIterator() {
final Iterator<Entry<K, V>> iterator = delegate.entrySet().iterator();
Iterator<Entry<K, V>> iterator = delegate.entrySet().iterator();
return new Iterator<Entry<K, V>>() {
@Nullable Entry<K, V> entry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,13 +930,13 @@ final Set<K> createMaybeNavigableKeySet() {

@WeakOuter
private class KeySet extends Maps.KeySet<K, Collection<V>> {
KeySet(final Map<K, Collection<V>> subMap) {
KeySet(Map<K, Collection<V>> subMap) {
super(subMap);
}

@Override
public Iterator<K> iterator() {
final Iterator<Entry<K, Collection<V>>> entryIterator = map().entrySet().iterator();
Iterator<Entry<K, Collection<V>>> entryIterator = map().entrySet().iterator();
return new Iterator<K>() {
@Nullable Entry<K, Collection<V>> entry;

Expand Down
8 changes: 4 additions & 4 deletions android/guava/src/com/google/common/collect/ArrayTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public boolean isEmpty() {
return keyIndex.isEmpty();
}

Entry<K, V> getEntry(final int index) {
Entry<K, V> getEntry(int index) {
checkElementIndex(index, size());
return new AbstractMapEntry<K, V>() {
@Override
Expand All @@ -246,7 +246,7 @@ public V setValue(@ParametricNullness V value) {
Iterator<Entry<K, V>> entryIterator() {
return new AbstractIndexedListIterator<Entry<K, V>>(size()) {
@Override
protected Entry<K, V> get(final int index) {
protected Entry<K, V> get(int index) {
return getEntry(index);
}
};
Expand Down Expand Up @@ -544,13 +544,13 @@ public int size() {
Iterator<Cell<R, C, @Nullable V>> cellIterator() {
return new AbstractIndexedListIterator<Cell<R, C, @Nullable V>>(size()) {
@Override
protected Cell<R, C, @Nullable V> get(final int index) {
protected Cell<R, C, @Nullable V> get(int index) {
return getCell(index);
}
};
}

private Cell<R, C, @Nullable V> getCell(final int index) {
private Cell<R, C, @Nullable V> getCell(int index) {
return new Tables.AbstractCell<R, C, @Nullable V>() {
final int rowIndex = index / columnList.size();
final int columnIndex = index % columnList.size();
Expand Down
Loading

0 comments on commit c4965e4

Please sign in to comment.