Skip to content

Commit

Permalink
Manually annotate some more type arguments as @Nullable.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 524863563
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Apr 17, 2023
1 parent 378386b commit 3f039fc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Expand Up @@ -274,7 +274,7 @@ public void testCompositionWildcard() {
Functions.compose(numberToSpanish, japaneseToInteger);
}

private static class HashCodeFunction implements Function<Object, Integer> {
private static class HashCodeFunction implements Function<@Nullable Object, Integer> {
@Override
public Integer apply(@Nullable Object o) {
return (o == null) ? 0 : o.hashCode();
Expand Down
Expand Up @@ -1326,16 +1326,16 @@ public void testSynchronizedBiMap() {
assertEquals(ImmutableSet.of(1, 2, 3), sync.inverse().keySet());
}

static final Predicate<String> NOT_LENGTH_3 =
new Predicate<String>() {
static final Predicate<@Nullable String> NOT_LENGTH_3 =
new Predicate<@Nullable String>() {
@Override
public boolean apply(@Nullable String input) {
return input == null || input.length() != 3;
}
};

static final Predicate<Integer> EVEN =
new Predicate<Integer>() {
static final Predicate<@Nullable Integer> EVEN =
new Predicate<@Nullable Integer>() {
@Override
public boolean apply(@Nullable Integer input) {
return input == null || input % 2 == 0;
Expand Down
Expand Up @@ -42,7 +42,7 @@ public class TreeMultimapExplicitTest extends TestCase {
* Compare strings lengths, and if the lengths are equal compare the strings. A {@code null} is
* less than any non-null value.
*/
private enum StringLength implements Comparator<String> {
private enum StringLength implements Comparator<@Nullable String> {
COMPARATOR;

@Override
Expand Down
2 changes: 1 addition & 1 deletion guava-tests/test/com/google/common/base/FunctionsTest.java
Expand Up @@ -274,7 +274,7 @@ public void testCompositionWildcard() {
Functions.compose(numberToSpanish, japaneseToInteger);
}

private static class HashCodeFunction implements Function<Object, Integer> {
private static class HashCodeFunction implements Function<@Nullable Object, Integer> {
@Override
public Integer apply(@Nullable Object o) {
return (o == null) ? 0 : o.hashCode();
Expand Down
8 changes: 4 additions & 4 deletions guava-tests/test/com/google/common/collect/MapsTest.java
Expand Up @@ -1371,16 +1371,16 @@ public void testSynchronizedBiMap() {
assertEquals(ImmutableSet.of(1, 2, 3), sync.inverse().keySet());
}

static final Predicate<String> NOT_LENGTH_3 =
new Predicate<String>() {
static final Predicate<@Nullable String> NOT_LENGTH_3 =
new Predicate<@Nullable String>() {
@Override
public boolean apply(@Nullable String input) {
return input == null || input.length() != 3;
}
};

static final Predicate<Integer> EVEN =
new Predicate<Integer>() {
static final Predicate<@Nullable Integer> EVEN =
new Predicate<@Nullable Integer>() {
@Override
public boolean apply(@Nullable Integer input) {
return input == null || input % 2 == 0;
Expand Down
Expand Up @@ -42,7 +42,7 @@ public class TreeMultimapExplicitTest extends TestCase {
* Compare strings lengths, and if the lengths are equal compare the strings. A {@code null} is
* less than any non-null value.
*/
private enum StringLength implements Comparator<String> {
private enum StringLength implements Comparator<@Nullable String> {
COMPARATOR;

@Override
Expand Down

0 comments on commit 3f039fc

Please sign in to comment.