Skip to content

Commit d826895

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Address a few more Error Prone warnings.
RELNOTES=n/a PiperOrigin-RevId: 745214427
1 parent 07426bc commit d826895

File tree

8 files changed

+13
-29
lines changed

8 files changed

+13
-29
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,4 @@ public final String join(Joiner joiner) {
844844
public final E get(int position) {
845845
return Iterables.get(getDelegate(), position);
846846
}
847-
848-
/** Function that transforms {@code Iterable<E>} into a fluent iterable. */
849-
private static class FromIterableFunction<E extends @Nullable Object>
850-
implements Function<Iterable<E>, FluentIterable<E>> {
851-
@Override
852-
public FluentIterable<E> apply(Iterable<E> fromObject) {
853-
return FluentIterable.from(fromObject);
854-
}
855-
}
856847
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,13 @@ public Map<R, V2> column(@ParametricNullness C columnKey) {
476476
return Maps.transformValues(fromTable.column(columnKey), function);
477477
}
478478

479-
Function<Cell<R, C, V1>, Cell<R, C, V2>> cellFunction() {
480-
return cell ->
481-
immutableCell(cell.getRowKey(), cell.getColumnKey(), function.apply(cell.getValue()));
479+
Cell<R, C, V2> applyToValue(Cell<R, C, V1> cell) {
480+
return immutableCell(cell.getRowKey(), cell.getColumnKey(), function.apply(cell.getValue()));
482481
}
483482

484483
@Override
485484
Iterator<Cell<R, C, V2>> cellIterator() {
486-
return Iterators.transform(fromTable.cellSet().iterator(), cellFunction());
485+
return Iterators.transform(fromTable.cellSet().iterator(), this::applyToValue);
487486
}
488487

489488
@Override

android/guava/src/com/google/common/eventbus/Dispatcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private static final class PerThreadQueuedDispatcher extends Dispatcher {
7676
// This dispatcher matches the original dispatch behavior of EventBus.
7777

7878
/** Per-thread queue of events to dispatch. */
79+
@SuppressWarnings("ThreadLocalUsage") // Each Dispatcher needs its own state.
7980
private final ThreadLocal<Queue<Event>> queue =
8081
new ThreadLocal<Queue<Event>>() {
8182
@Override
@@ -85,6 +86,7 @@ protected Queue<Event> initialValue() {
8586
};
8687

8788
/** Per-thread dispatch state, used to avoid reentrant event dispatching. */
89+
@SuppressWarnings("ThreadLocalUsage") // Each Dispatcher needs its own state.
8890
private final ThreadLocal<Boolean> dispatching =
8991
new ThreadLocal<Boolean>() {
9092
@Override

android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* <ul>
4040
* <li>Multiple events for the same listener are never dispatched concurrently.
4141
* <li>Events for the different listeners are dispatched concurrently.
42-
* <li>All events for a given listener dispatch on the provided {@link #executor}.
42+
* <li>All events for a given listener dispatch on the provided executor.
4343
* <li>It is easy for the user to ensure that listeners are never invoked while holding locks.
4444
* </ul>
4545
*

guava/src/com/google/common/collect/FluentIterable.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -849,13 +849,4 @@ public final E get(int position) {
849849
public final Stream<E> stream() {
850850
return Streams.stream(getDelegate());
851851
}
852-
853-
/** Function that transforms {@code Iterable<E>} into a fluent iterable. */
854-
private static class FromIterableFunction<E extends @Nullable Object>
855-
implements Function<Iterable<E>, FluentIterable<E>> {
856-
@Override
857-
public FluentIterable<E> apply(Iterable<E> fromObject) {
858-
return FluentIterable.from(fromObject);
859-
}
860-
}
861852
}

guava/src/com/google/common/collect/Tables.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,19 +478,18 @@ public Map<R, V2> column(@ParametricNullness C columnKey) {
478478
return Maps.transformValues(fromTable.column(columnKey), function);
479479
}
480480

481-
Function<Cell<R, C, V1>, Cell<R, C, V2>> cellFunction() {
482-
return cell ->
483-
immutableCell(cell.getRowKey(), cell.getColumnKey(), function.apply(cell.getValue()));
481+
Cell<R, C, V2> applyToValue(Cell<R, C, V1> cell) {
482+
return immutableCell(cell.getRowKey(), cell.getColumnKey(), function.apply(cell.getValue()));
484483
}
485484

486485
@Override
487486
Iterator<Cell<R, C, V2>> cellIterator() {
488-
return Iterators.transform(fromTable.cellSet().iterator(), cellFunction());
487+
return Iterators.transform(fromTable.cellSet().iterator(), this::applyToValue);
489488
}
490489

491490
@Override
492491
Spliterator<Cell<R, C, V2>> cellSpliterator() {
493-
return CollectSpliterators.map(fromTable.cellSet().spliterator(), cellFunction());
492+
return CollectSpliterators.map(fromTable.cellSet().spliterator(), this::applyToValue);
494493
}
495494

496495
@Override

guava/src/com/google/common/eventbus/Dispatcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private static final class PerThreadQueuedDispatcher extends Dispatcher {
7676
// This dispatcher matches the original dispatch behavior of EventBus.
7777

7878
/** Per-thread queue of events to dispatch. */
79+
@SuppressWarnings("ThreadLocalUsage") // Each Dispatcher needs its own state.
7980
private final ThreadLocal<Queue<Event>> queue =
8081
new ThreadLocal<Queue<Event>>() {
8182
@Override
@@ -85,6 +86,7 @@ protected Queue<Event> initialValue() {
8586
};
8687

8788
/** Per-thread dispatch state, used to avoid reentrant event dispatching. */
89+
@SuppressWarnings("ThreadLocalUsage") // Each Dispatcher needs its own state.
8890
private final ThreadLocal<Boolean> dispatching =
8991
new ThreadLocal<Boolean>() {
9092
@Override

guava/src/com/google/common/util/concurrent/ListenerCallQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* <ul>
4040
* <li>Multiple events for the same listener are never dispatched concurrently.
4141
* <li>Events for the different listeners are dispatched concurrently.
42-
* <li>All events for a given listener dispatch on the provided {@link #executor}.
42+
* <li>All events for a given listener dispatch on the provided executor.
4343
* <li>It is easy for the user to ensure that listeners are never invoked while holding locks.
4444
* </ul>
4545
*

0 commit comments

Comments
 (0)