From a0b901c3c04d0377f495a9da853196a3b0433eae Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 4 Jun 2018 23:55:13 +0200 Subject: `@NonNull` now uses a slightly longer exception message. --- website/templates/features/NonNull.html | 4 ++-- website/usageExamples/NonNullExample_post.jpage | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'website') diff --git a/website/templates/features/NonNull.html b/website/templates/features/NonNull.html index 28d083d0..3d99a3c7 100644 --- a/website/templates/features/NonNull.html +++ b/website/templates/features/NonNull.html @@ -11,7 +11,7 @@

Lombok has always treated any annotation named @NonNull on a field as a signal to generate a null-check if lombok generates an entire method or constructor for you, via for example @Data. Now, however, using lombok's own @lombok.NonNull on a parameter results in the insertion of just the null-check statement inside your own method or constructor.

- The null-check looks like if (param == null) throw new NullPointerException("param"); and will be inserted at the very top of your method. For constructors, the null-check will be inserted immediately following any explicit this() or super() calls. + The null-check looks like if (param == null) throw new NullPointerException("param is marked @NonNull but is null"); and will be inserted at the very top of your method. For constructors, the null-check will be inserted immediately following any explicit this() or super() calls.

If a null-check is already present at the top, no additional null-check will be generated.

@@ -23,7 +23,7 @@
lombok.nonNull.exceptionType = [NullPointerException | IllegalArgumentException] (default: NullPointerException).
- When lombok generates a null-check if statement, by default, a java.lang.NullPointerException will be thrown with the field name as the exception message. However, you can use IllegalArgumentException in this configuration key to have lombok throw that exception, with 'fieldName is null' as exception message. + When lombok generates a null-check if statement, by default, a java.lang.NullPointerException will be thrown with 'field name is marked @NonNull but is null' as the exception message. However, you can use IllegalArgumentException in this configuration key to have lombok throw that exception with this message instead.
lombok.nonNull.flagUsage = [warning | error] (default: not set)
diff --git a/website/usageExamples/NonNullExample_post.jpage b/website/usageExamples/NonNullExample_post.jpage index 24175e06..bb67b3f6 100644 --- a/website/usageExamples/NonNullExample_post.jpage +++ b/website/usageExamples/NonNullExample_post.jpage @@ -6,7 +6,7 @@ public class NonNullExample extends Something { public NonNullExample(@NonNull Person person) { super("Hello"); if (person == null) { - throw new NullPointerException("person"); + throw new NullPointerException("person is marked @NonNull but is null"); } this.name = person.getName(); } -- cgit