From f12b7059ca0afa60ca50d0410ea84a3f92e22dd6 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 6 Feb 2020 21:47:27 +0100 Subject: [issue #1197] fixed documentation of NonNull It did not mention the Guava and JDK options. --- website/templates/features/NonNull.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'website/templates/features') diff --git a/website/templates/features/NonNull.html b/website/templates/features/NonNull.html index e01a3088..67cc262c 100644 --- a/website/templates/features/NonNull.html +++ b/website/templates/features/NonNull.html @@ -21,9 +21,9 @@ <@f.confKeys>
- lombok.nonNull.exceptionType = [NullPointerException | IllegalArgumentException | Assertion] (default: NullPointerException). + lombok.nonNull.exceptionType = [NullPointerException | IllegalArgumentException | JDK | Guava | Assertion] (default: NullPointerException).
- When lombok generates a null-check if statement, by default, a java.lang.NullPointerException will be thrown with 'field name is marked non-null 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. By using Assertion, an assert statement with the same message will be generated. + When lombok generates a null-check if statement, by default, a java.lang.NullPointerException will be thrown with 'field name is marked non-null 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. By using Assertion, an assert statement with the same message will be generated. The keys JDK or Guava result in an invocation to the standard nullcheck method of these two frameworks: java.util.Objects.requireNonNull([field name here], "[field name here] is marked non-null but is null"); or com.google.common.base.Preconditions.checkNotNull([field name here], "[field name here] is marked non-null but is null"); respectively.
lombok.nonNull.flagUsage = [warning | error] (default: not set)
@@ -33,7 +33,7 @@ <@f.smallPrint>

- Lombok's detection scheme for already existing null-checks consists of scanning for if statements or assert statements that look just like lombok's own. Any 'throws' statement as the 'then' part of the if statement, whether in braces or not, counts. The conditional of the if statement must look exactly like PARAMNAME == null; the assert statement must look exactly like PARAMNAME != null. The first statement in your method that is not such a null-check stops the process of inspecting for null-checks. + Lombok's detection scheme for already existing null-checks consists of scanning for if statements or assert statements that look just like lombok's own. Any 'throws' statement as the 'then' part of the if statement, whether in braces or not, counts. Any invocation to any method named requireNonNull or checkNotNull counts. The conditional of the if statement must look exactly like PARAMNAME == null; the assert statement must look exactly like PARAMNAME != null. The invocation to a requireNonNull-style method must be on its own (a statement which just invokes that method), or must be the expression of an assignment or variable declaration statement. The first statement in your method that is not such a null-check stops the process of inspecting for null-checks.

While @Data and other method-generating lombok annotations will trigger on various well-known annotations that signify the field must never be @NonNull, this feature only triggers on lombok's own @NonNull annotation from the lombok package.

-- cgit