mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-17 02:14:16 +00:00
[issue #1938] addressing some small issues with the documentation.
This commit is contained in:
1 parent
db19327cb4
commit
94d11d89a7
6 files changed
+15
-6
No files matched your search
@@ -45,6 +45,10 @@
|
||||
<code>lombok.getter.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
</dt><dd>
|
||||
Lombok will flag any usage of <code>@Getter</code> as a warning or error if configured.
|
||||
</dd><dt>
|
||||
<code>lombok.copyableAnnotations</code> = [<em>A list of fully qualified types</em>] (default: empty list)
|
||||
</dt><dd>
|
||||
Lombok will copy any of these annotations from the field to the setter parameter, and to the getter method. Note that lombok ships with a bunch of annotations 'out of the box' which are known to be copyable: All popular nullable/nonnull annotations.
|
||||
</dd>
|
||||
</@f.confKeys>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<p>
|
||||
You can use <code>@NonNull</code> on the parameter of a method or constructor to have lombok generate a null-check statement for you.
|
||||
</p><p>
|
||||
Lombok has always treated any annotation named <code>@NonNull</code> on a field as a signal to generate a null-check if lombok generates an entire method or constructor for you, via for example <a href="/features/Data"><code>@Data</code></a>. Now, however, using lombok's own <code>@lombok.NonNull</code> on a parameter results in the insertion of just the null-check statement inside your own method or constructor.
|
||||
Lombok has always treated various annotations generally named <code>@NonNull</code> on a field as a signal to generate a null-check if lombok generates an entire method or constructor for you, via for example <a href="/features/Data"><code>@Data</code></a>. Now, however, using lombok's own <code>@lombok.NonNull</code> on a parameter results in the insertion of just the null-check statement inside your own method or constructor.
|
||||
</p><p>
|
||||
The null-check looks like <code>if (param == null) throw new NullPointerException("param is marked @NonNull but is null");</code> and will be inserted at the very top of your method. For constructors, the null-check will be inserted immediately following any explicit <code>this()</code> or <code>super()</code> calls.
|
||||
</p><p>
|
||||
@@ -35,7 +35,7 @@
|
||||
<p>
|
||||
Lombok's detection scheme for already existing null-checks consists of scanning for if 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 <em>must</em> look exactly like <code>PARAMNAME == null</code>. The first statement in your method that is not such a null-check stops the process of inspecting for null-checks.
|
||||
</p><p>
|
||||
While <code>@Data</code> and other method-generating lombok annotations will trigger on any annotation named <code>@NonNull</code> regardless of casing or package name, this feature only triggers on lombok's own <code>@NonNull</code> annotation from the <code>lombok</code> package.
|
||||
While <code>@Data</code> and other method-generating lombok annotations will trigger on various well-known annotations that signify the field must never be <code>@NonNull</code>, this feature only triggers on lombok's own <code>@NonNull</code> annotation from the <code>lombok</code> package.
|
||||
</p><p>
|
||||
A <code>@NonNull</code> on a primitive parameter results in a warning. No null-check will be generated.
|
||||
</p><p>
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
<code>lombok.anyConstructor.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
</dt><dd>
|
||||
Lombok will flag any usage of any of the 3 constructor-generating annotations as a warning or error if configured.
|
||||
</dd><dt>
|
||||
<code>lombok.copyableAnnotations</code> = [<em>A list of fully qualified types</em>] (default: empty list)
|
||||
</dt><dd>
|
||||
Lombok will copy any of these annotations from the field to the constructor parameter, the setter parameter, and the getter method. Note that lombok ships with a bunch of annotations 'out of the box' which are known to be copyable: All popular nullable/nonnull annotations.
|
||||
</dd>
|
||||
</@f.confKeys>
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<@f.smallPrint>
|
||||
<p>
|
||||
Starting with lombok v1.18.5, lombok will silently skip generating anything that already exists. You can define the inner <code>Fields</code> enum/class yourself,
|
||||
Starting with lombok v1.18.6, lombok will silently skip generating anything that already exists. You can define the inner <code>Fields</code> enum/class yourself,
|
||||
in which case lombok will add all the enum constants / public static final fields you haven't written yourself.
|
||||
</p><p>
|
||||
From lombok v1.16.22 to lombok v1.18.2, this feature generated constants inside the type directly; the name of these fields would for example turn field <code>exampleFieldName</code> into <code>public static final String FIELD_EXAMPLE_FIELD_NAME = "exampleFieldName";</code>. The prefix and suffix (here, <code>FIELD_</code>, and the empty string) were configurable. Starting with lombok v1.18.4 this feature has been redesigned into generating an inner type as described above.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
public class FieldNameConstantsExample {
|
||||
private final String iAmAField;
|
||||
private final int andSoAmI;
|
||||
private final int asAmI;
|
||||
|
||||
public static final class Fields {
|
||||
public static final String iAmAField = "IAmAField";
|
||||
static final String andSoAmI = "andSoAmI";
|
||||
public static final String iAmAField = "iAmAField";
|
||||
public static final String andSoAmI = "andSoAmI";
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ import lombok.AccessLevel;
|
||||
@FieldNameConstants
|
||||
public class FieldNameConstantsExample {
|
||||
private final String iAmAField;
|
||||
@FieldNameConstants(level = AccessLevel.PACKAGE)
|
||||
private final int andSoAmI;
|
||||
@FieldNameConstants.Exclude private final int asAmI;
|
||||
}
|
||||
Reference in new issue
Block a user