From 8b7a7cbc813653a3248d6cf3a7779e220957bc85 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 8 May 2017 21:28:02 +0200 Subject: The great rename: the old ‘website’ is now ‘website-old’, and ‘website2’ is now ‘website’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/features/experimental/Helper.html | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 website/templates/features/experimental/Helper.html (limited to 'website/templates/features/experimental/Helper.html') diff --git a/website/templates/features/experimental/Helper.html b/website/templates/features/experimental/Helper.html new file mode 100644 index 00000000..93b6e2b4 --- /dev/null +++ b/website/templates/features/experimental/Helper.html @@ -0,0 +1,52 @@ +<#import "../_features.html" as f> + +<@f.scaffold title="@Helper" logline="With a little help from my friends... Helper methods for java."> + <@f.history> +

+ @Helper was introduced as an experimental feature in lombok v1.16.6. +

+ + + <@f.experimental> + + Current status: unknown - We don't have enough experience with this feature to make predictions on its future. + + + <@f.overview> +

+ This annotation lets you put methods in methods. You might not know this, but you can declare classes inside methods, and the methods in this class can access any (effectively) final local variable or parameter defined and set before the declaration. Unfortunately, to actually call any methods you'd have to make an instance of this method local class first, but that's where @Helper comes in and helps you out! Annotate a method local class with @Helper and it's as if all the methods in that helper class are methods that you can call directly, just as if java had allowed methods to exist inside methods. +

+ Normally you'd have to declare an instance of your helper, for example: HelperClass h = new HelperClass(); directly after declaring your helper class, and then call methods in your helper class with h.helperMethod();. With @Helper, both of these things are no longer needed: You do not need to waste a line of code declaring an instance of the helper, and you don't need to prefix all your calls to helper methods with nameOfHelperInstance. +

+ + + <@f.snippets name="experimental/Helper" /> + + <@f.confKeys> +
+ lombok.helper.flagUsage = [warning | error] (default: not set) +
+ Lombok will flag any usage of @Helper as a warning or error if configured. +
+ + + <@f.smallPrint> +

+ @Helper requires that the helper class has a no-args constructor. A compiler error will be generated if this is not the case. +

+ Currently, the instance of your helper that's made under the hood is called $Foo, where Foo is the name of your helper. We might change this in the future; please don't rely on this variable existing. We might even replace this later with a sibling method instead. +

+ Please don't rely on this making any sense in the helper method code. You can refer to the real 'this' by using the syntax NameOfMyClass.this. +

+ ANY unqualified method call in code that exists below the declaration of the helper method with the same name as any method in the helper is assumed to be a call to the helper. If the arguments don't end up being compatible, you get a compiler error. +

+ Unless you're using JDK8 or higher (which introduced the concept of 'effectively final'), you'll have to declare local variables and parameters as final if you wish to refer to them in your method local class. This is a java limitation, not something specific to lombok's @Helper. +

+ + -- cgit