diff options
author | Éamonn McManus <emcmanus@google.com> | 2021-10-19 17:35:10 -0700 |
---|---|---|
committer | Google Java Core Libraries <java-libraries-firehose+copybara@google.com> | 2021-10-19 17:35:55 -0700 |
commit | 8abfb9cdd873457a0696df08c38cb7f04d7208f9 (patch) | |
tree | 9feb2e87be8e2f967982142b309c77d0f5b6ff13 /value/src | |
parent | e0740327d830597e17273946418f6adc976bc619 (diff) | |
download | auto-8abfb9cdd873457a0696df08c38cb7f04d7208f9.tar.gz |
Use `Objects.requireNonNull(x)` instead of `x.getClass()` in no-identifiers mode.
RELNOTES=n/a
PiperOrigin-RevId: 404405947
Diffstat (limited to 'value/src')
-rw-r--r-- | value/src/main/java/com/google/auto/value/processor/autovalue.vm | 6 | ||||
-rw-r--r-- | value/src/main/java/com/google/auto/value/processor/builder.vm | 6 |
2 files changed, 2 insertions, 10 deletions
diff --git a/value/src/main/java/com/google/auto/value/processor/autovalue.vm b/value/src/main/java/com/google/auto/value/processor/autovalue.vm index 86cfe493..18ca827a 100644 --- a/value/src/main/java/com/google/auto/value/processor/autovalue.vm +++ b/value/src/main/java/com/google/auto/value/processor/autovalue.vm @@ -75,15 +75,11 @@ ${modifiers}class $subclass$formalTypes extends $origClass$actualTypes { ## the constructor is called from the extension code. #if ($identifiers) - if ($p == null) { throw new NullPointerException("Null $p.name"); } #else - ## Just throw NullPointerException with no message if it's null. - ## The Object cast has no effect on the code but silences an ErrorProne warning. - - ((`java.lang.Object`) ${p}).getClass(); + `java.util.Objects`.requireNonNull($p); #end #end diff --git a/value/src/main/java/com/google/auto/value/processor/builder.vm b/value/src/main/java/com/google/auto/value/processor/builder.vm index 950f9838..b1787f25 100644 --- a/value/src/main/java/com/google/auto/value/processor/builder.vm +++ b/value/src/main/java/com/google/auto/value/processor/builder.vm @@ -94,15 +94,11 @@ class ${builderName}${builderFormalTypes} ## #if (!$setter.primitiveParameter && !$p.nullable && ${setter.copy($p)} == $p) #if ($identifiers) - if ($p == null) { throw new NullPointerException("Null $p.name"); } #else - ## Just throw NullPointerException with no message if it's null. - ## The Object cast has no effect on the code but silences an ErrorProne warning. - - ((`java.lang.Object`) ${p}).getClass(); + `java.util.Objects`.requireNonNull($p); #end #end |