From 3369e0ffc73a8150f58d74c0e44ef59a9e160976 Mon Sep 17 00:00:00 2001 From: "J. Y. Terence Kim" Date: Mon, 23 Sep 2019 18:16:08 +0900 Subject: Update With.html ## Summary The current sentence fragment `Lombok's own @AllArgsConstructor` does not fully clarify the author's intention, which I presume is to recommend using `@AllArgsConstructor`. --- website/templates/features/With.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'website/templates') diff --git a/website/templates/features/With.html b/website/templates/features/With.html index f1719e19..425a1640 100644 --- a/website/templates/features/With.html +++ b/website/templates/features/With.html @@ -14,7 +14,7 @@

For example, if you create public class Point { private final int x, y; }, setters make no sense because the fields are final. @With can generate a withX(int newXValue) method for you which will return a new point with the supplied value for x and the same value for y.

- The @With relies on a constructor for all fields in order to do its work. If this constructor does not exist, your @With annotation will result in a compile time error message. Lombok's own @AllArgsConstructor. As Value will automatically produce an all args constructor as well, you can use that too. It's of course also acceptable if you manually write this constructor. It must contain all non-static fields, in the same lexical order. + The @With relies on a constructor for all fields in order to do its work. If this constructor does not exist, your @With annotation will result in a compile time error message. You can use Lombok's own @AllArgsConstructor, or as Value will automatically produce an all args constructor as well, you can use that too. It's of course also acceptable if you manually write this constructor. It must contain all non-static fields, in the same lexical order.

Like @Setter, you can specify an access level in case you want the generated with method to be something other than public:
@With(level = AccessLevel.PROTECTED). Also like @Setter, you can also put a @With annotation on a type, which means a with method is generated for each field (even non-final fields).

-- cgit