diff options
-rw-r--r-- | src/core/lombok/NonNull.java | 4 | ||||
-rw-r--r-- | src/utils/lombok/core/TransformationsUtil.java | 6 | ||||
-rw-r--r-- | website/features/Data.html | 2 | ||||
-rw-r--r-- | website/features/GetterSetter.html | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/src/core/lombok/NonNull.java b/src/core/lombok/NonNull.java index 96184dcd..b3d3c348 100644 --- a/src/core/lombok/NonNull.java +++ b/src/core/lombok/NonNull.java @@ -28,12 +28,12 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Lombok is smart enough to translate any annotation named {@code @NonNull} or {@code @NotNull} in any casing and + * Lombok is smart enough to translate any annotation named {@code @NonNull} in any casing and * with any package name to the return type of generated getters and the parameter of generated setters and constructors, * as well as generate the appropriate null checks in the setter and constructor. * * You can use this annotation for the purpose, though you can also use JSR305's annotation, findbugs's, pmd's, or IDEA's, or just - * about anyone elses. As long as it is named {@code @NonNull} or {@code @NotNull}. + * about anyone elses. As long as it is named {@code @NonNull}. * * WARNING: If the java community ever does decide on supporting a single {@code @NonNull} annotation (for example via JSR305), then * this annotation will <strong>be deleted</strong> from the lombok package. If the need to update an import statement scares diff --git a/src/utils/lombok/core/TransformationsUtil.java b/src/utils/lombok/core/TransformationsUtil.java index 3fbfef58..25c3215a 100644 --- a/src/utils/lombok/core/TransformationsUtil.java +++ b/src/utils/lombok/core/TransformationsUtil.java @@ -72,7 +72,11 @@ public class TransformationsUtil { public static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile( "^(boolean|byte|short|int|long|float|double|char)$"); - public static final Pattern NON_NULL_PATTERN = Pattern.compile("^(?:notnull|nonnull)$", Pattern.CASE_INSENSITIVE); + /* NB: 'notnull' is not part of the pattern because there are lots of @NotNull annotations out there that are crappily named and actually mean + something else, such as 'this field must not be null _when saved to the db_ but its perfectly okay to start out as such, and a no-args + constructor and the implied starts-out-as-null state that goes with it is in fact mandatory' which happens with javax.validation.constraints.NotNull. + Various problems with spring have also been reported. See issue #287, issue #271, and issue #43. */ + public static final Pattern NON_NULL_PATTERN = Pattern.compile("^(?:nonnull)$", Pattern.CASE_INSENSITIVE); public static final Pattern NULLABLE_PATTERN = Pattern.compile("^(?:nullable|checkfornull)$", Pattern.CASE_INSENSITIVE); /** diff --git a/website/features/Data.html b/website/features/Data.html index 03f6eb2a..e54b2de6 100644 --- a/website/features/Data.html +++ b/website/features/Data.html @@ -21,7 +21,7 @@ and <a href="Constructor.html"><code>@RequiredArgsConstructor</code></a> together: In other words, <code>@Data</code> generates <em>all</em> the boilerplate that is normally associated with simple POJOs (Plain Old Java Objects) and beans: getters for all fields, setters for all non-final fields, and appropriate <code>toString</code>, <code>equals</code> and <code>hashCode</code> implementations that involve the fields of the class, and a constructor that - initializes all final fields, as well as all non-final fields with no initializer that have been marked with <code>@NonNull</code> or <code>@NotNull</code>, + initializes all final fields, as well as all non-final fields with no initializer that have been marked with <code>@NonNull</code>, in order to ensure the field is never null. </p><p> <code>@Data</code> is like having implicit <code>@Getter</code>, <code>@Setter</code>, <code>@ToString</code>, <code>@EqualsAndHashCode</code> and <code>@RequiredArgsConstructor</code> diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html index 51a1f514..3e3530ef 100644 --- a/website/features/GetterSetter.html +++ b/website/features/GetterSetter.html @@ -58,7 +58,7 @@ Any variation on <code>boolean</code> will <em>not</em> result in using the <code>is</code> prefix instead of the <code>get</code> prefix; for example, returning <code>java.lang.Boolean</code> results in a <code>get</code> prefix, not an <code>is</code> prefix. </p><p> - Any annotations named <code>@NonNull</code> or <code>@NotNull</code> (case insensitive) on the field are interpreted as: This field must not ever hold + Any annotations named <code>@NonNull</code> (case insensitive) on the field are interpreted as: This field must not ever hold <em>null</em>. Therefore, these annotations result in an explicit null check in the generated setter. Also, these annotations (as well as any annotation named <code>@Nullable</code> or <code>@CheckForNull</code>) are copied to setter parameter and getter method. </p><p> |