From ee7a38654d0fada980f533e4bb051a2008c99845 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Fri, 9 Sep 2022 16:52:21 +0200 Subject: [PATCH] Suggestions 2 --- .../errorprone/refastertemplates/NullTemplates.java | 10 ++++------ .../refastertemplates/NullTemplatesTestInput.java | 4 ++-- .../refastertemplates/NullTemplatesTestOutput.java | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java index fe80dbdf9f5..276a277bca7 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java @@ -58,10 +58,9 @@ Predicate after() { } /** - * Prefer the == operator over {@link java.util.Objects#isNull(Object)} for null - * checks. + * Prefer the {@code ==} operator over {@link java.util.Objects#isNull(Object)} for null checks. */ - static final class ObjectEqualsNull { + static final class IsNull { @BeforeTemplate boolean before(@Nullable Object object) { return Objects.isNull(object); @@ -74,10 +73,9 @@ boolean after(@Nullable Object object) { } /** - * Prefer the != operator over {@link java.util.Objects#isNull(Object)} for null - * checks. + * Prefer the {@code !=} operator over {@link java.util.Objects#isNull(Object)} for null checks. */ - static final class ObjectNotEqualsNull { + static final class IsNotNull { @BeforeTemplate boolean before(@Nullable Object object) { return Objects.nonNull(object); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestInput.java index a633fc35df4..77d7447b997 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestInput.java @@ -24,11 +24,11 @@ long testNonNullFunction() { return Stream.of("foo").filter(s -> s != null).count(); } - boolean testObjectEqualsNull() { + boolean testIsNull() { return Objects.isNull("foo"); } - boolean testObjectNotEqualsNull() { + boolean testIsNotNull() { return Objects.nonNull("foo"); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestOutput.java index 0926a6d5569..84c312fd4ec 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/NullTemplatesTestOutput.java @@ -26,11 +26,11 @@ long testNonNullFunction() { return Stream.of("foo").filter(Objects::nonNull).count(); } - boolean testObjectEqualsNull() { + boolean testIsNull() { return "foo" == null; } - boolean testObjectNotEqualsNull() { + boolean testIsNotNull() { return "foo" != null; } }