From a24bf3194477a841c905827ef625e19b0fd53b2a Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 6 Jan 2017 01:21:28 +0100 Subject: feature pages updated and made more consistent. --- website2/templates/features/EqualsAndHashCode.html | 8 +++-- website2/templates/features/NonNull.html | 2 ++ website2/templates/features/_features.html | 3 +- website2/templates/features/builder.html | 30 ++++++++++++------ website2/templates/features/builderSingular.html | 5 +++ website2/templates/features/configuration.html | 13 ++++++++ website2/templates/features/constructor.html | 4 +-- website2/templates/features/data.html | 2 +- .../features/experimental/FieldDefaults.html | 12 +++++-- .../features/experimental/UtilityClass.html | 4 ++- .../templates/features/experimental/index.html | 24 ++++++++------ website2/templates/features/experimental/onX.html | 3 +- website2/templates/features/experimental/var.html | 37 ++++++++++++++++++++++ website2/templates/features/index.html | 32 +++++++++---------- website2/templates/features/log.html | 10 +++++- website2/templates/features/val.html | 7 +++- website2/templates/features/value.html | 4 +-- 17 files changed, 149 insertions(+), 51 deletions(-) create mode 100644 website2/templates/features/builderSingular.html create mode 100644 website2/templates/features/experimental/var.html (limited to 'website2/templates') diff --git a/website2/templates/features/EqualsAndHashCode.html b/website2/templates/features/EqualsAndHashCode.html index 91a9cb70..3c11367f 100644 --- a/website2/templates/features/EqualsAndHashCode.html +++ b/website2/templates/features/EqualsAndHashCode.html @@ -5,9 +5,9 @@

Any class definition may be annotated with @EqualsAndHashCode to let lombok generate implementations of the equals(Object other) and hashCode() methods. By default, it'll use all non-static, non-transient fields, but you can exclude more fields by naming them in the optional exclude parameter to the annotation. Alternatively, you can specify exactly which fields you wish to be used by naming them in the of parameter.

- By setting callSuper to true, you can include the equals and hashCode methods of your superclass in the generated methods. For hashCode, the result of super.hashCode() is included in the hash algorithm, and for equals, the generated method will return false if the super implementation thinks it is not equal to the passed in object. Be aware that not all equals implementations handle this situation properly. However, lombok-generated equals implementations do handle this situation properly, so you can safely call your superclass equals if it, too, has a lombok-generated equals method.
+ If applying @EqualsAndHashCode to a class that extends another, this feature gets a bit trickier. Normally, auto-generating an equals and hashCode method for such classes is a bad idea, as the superclass also defines fields, which also need equals/hashCode code but this code will not be generated. By setting callSuper to true, you can include the equals and hashCode methods of your superclass in the generated methods. For hashCode, the result of super.hashCode() is included in the hash algorithm, and forequals, the generated method will return false if the super implementation thinks it is not equal to the passed in object. Be aware that not all equals implementations handle this situation properly. However, lombok-generated equals implementations do handle this situation properly, so you can safely call your superclass equals if it, too, has a lombok-generated equals method. If you have an explicit superclass you are forced to supply some value for callSuper to acknowledge that you've considered it; failure to do so results in a warning.

- Setting callSuper to true when you don't extend anything (you extend java.lang.Object) is a compile-time error, because it would turn the generated equals() and hashCode() implementations into having the same behaviour as simply inheriting these methods from java.lang.Object: only the same object will be equal to each other and will have the same hashCode. Not setting callSuper to true when you extend another class generates a warning, because unless the superclass has no (equality-important) fields, lombok cannot generate an implementation for you that takes into account the fields declared by your superclasses. You'll need to write your own implementations, or rely on the callSuper chaining facility. + Setting callSuper to true when you don't extend anything (you extend java.lang.Object) is a compile-time error, because it would turn the generated equals() and hashCode() implementations into having the same behaviour as simply inheriting these methods from java.lang.Object: only the same object will be equal to each other and will have the same hashCode. Not setting callSuper to true when you extend another class generates a warning, because unless the superclass has no (equality-important) fields, lombok cannot generate an implementation for you that takes into account the fields declared by your superclasses. You'll need to write your own implementations, or rely on the callSuper chaining facility. You can also use the lombok.equalsAndHashCode.callSuper config key.

NEW in Lombok 0.10: Unless your class is final and extends java.lang.Object, lombok generates a canEqual method which means JPA proxies can still be equal to their base class, but subclasses that add new state don't break the equals contract. The complicated reasons for why such a method is necessary are explained in this paper: How to Write an Equality Method in Java. If all classes in a hierarchy are a mix of scala case classes and classes with lombok-generated equals methods, all equality will 'just work'. If you need to write your own equals methods, you should always override canEqual if you change equals and hashCode.

@@ -22,6 +22,10 @@ lombok.equalsAndHashCode.doNotUseGetters = [true | false] (default: false)

If set to true, lombok will access fields directly instead of using getters (if available) when generating equals and hashCode methods. The annotation parameter 'doNotUseGetters', if explicitly specified, takes precedence over this setting. +
+ lombok.equalsAndHashCode.callSuper = [call | skip | warn] (default: warn) +
+ If set to call, lombok will generate calls to the superclass implementation of hashCode and equals if your class extends something. If set to skip no such calls are generated. The default behaviour is like skip, with an additional warning.
lombok.equalsAndHashCode.flagUsage = [warning | error] (default: not set)
diff --git a/website2/templates/features/NonNull.html b/website2/templates/features/NonNull.html index 60879085..28d083d0 100644 --- a/website2/templates/features/NonNull.html +++ b/website2/templates/features/NonNull.html @@ -38,6 +38,8 @@ While @Data and other method-generating lombok annotations will trigger on any annotation named @NonNull regardless of casing or package name, this feature only triggers on lombok's own @NonNull annotation from the lombok package.

A @NonNull on a primitive parameter results in a warning. No null-check will be generated. +

+ A @NonNull on a parameter of an abstract method used to generate a warning; starting with version 1.16.8, this is no longer the case, to acknowledge the notion that @NonNull also has a documentary role. For the same reason, you can annotate a method as @NonNull; this is allowed, generates no warning, and does not generate any code.

diff --git a/website2/templates/features/_features.html b/website2/templates/features/_features.html index bcfdee63..d7c75761 100644 --- a/website2/templates/features/_features.html +++ b/website2/templates/features/_features.html @@ -64,8 +64,7 @@ <#macro scaffold title logline load=[]> - <#assign load2=load + ["/js/history.js"]> - <@main.scaffold load2> + <@main.scaffold load>
Lombok will flag any usage of @FieldDefaults as a warning or error if configured. +
+ lombok.fieldDefautls.defaultPrivate = [true | false] (default: false) +
+ (Since 1.16.8) If set to true, every field in every class or enum anywhere in the sources being compiled will be marked as private unless it has an explicit access modifier or the @PackagePrivate annotation, or an explicit @FieldDefaults annotation is present to override this config key. +
+ lombok.fieldDefaults.defaultFinal = [true | false] (default: false) +
+ (Since 1.16.8) If set to true, every field in every class or enum anywhere in the sources being compiled will be marked as final unless it has the @NonFinal annotation, or an explicit @FieldDefaults annotation is present to override this config key.
diff --git a/website2/templates/features/experimental/UtilityClass.html b/website2/templates/features/experimental/UtilityClass.html index 8145437a..4cee3657 100644 --- a/website2/templates/features/experimental/UtilityClass.html +++ b/website2/templates/features/experimental/UtilityClass.html @@ -9,7 +9,9 @@ <@f.experimental> Current status: positive - Currently we feel this feature may move out of experimental status with no or minor changes soon. diff --git a/website2/templates/features/experimental/index.html b/website2/templates/features/experimental/index.html index 257c0382..65cefd4c 100644 --- a/website2/templates/features/experimental/index.html +++ b/website2/templates/features/experimental/index.html @@ -25,35 +25,39 @@

- <@main.feature title="@Accessors" code="/features/experimental/Accessors"> + <@main.feature title="var" href="var"> + Modifiable local variables with a type inferred by assigning value. + + + <@main.feature title="@Accessors" href="Accessors"> A more fluent API for getters and setters. - <@main.feature title="@ExtensionMethod" code="/features/experimental/ExtensionMethod"> + <@main.feature title="@ExtensionMethod" href="ExtensionMethod"> Annoying API? Fix it yourself: Add new methods to existing types! - <@main.feature title="@FieldDefaults" code="/features/experimental/FieldDefaults"> + <@main.feature title="@FieldDefaults" href="FieldDefaults"> New default field modifiers for the 21st century. - <@main.feature title="@Delegate" code="/features/experimental/Delegate"> + <@main.feature title="@Delegate" href="Delegate"> Don't lose your composition. - <@main.feature title="@Wither" code="/features/experimental/Wither"> + <@main.feature title="@Wither" href="Wither"> Immutable 'setters' - methods that create a clone but with one changed field. - <@main.feature title="onMethod= / onConstructor= / onParam=" code="/features/experimental/onX"> + <@main.feature title="onMethod= / onConstructor= / onParam=" href="onX"> Sup dawg, we heard you like annotations, so we put annotations in your annotations so you can annotate while you're annotating. - <@main.feature title="@UtilityClass" code="/features/experimental/UtilityClass"> + <@main.feature title="@UtilityClass" href="UtilityClass"> Utility, metility, wetility! Utility classes for the masses. - <@main.feature title="@Helper" code="/features/experimental/Helper"> + <@main.feature title="@Helper" href="Helper"> With a little help from my friends... Helper methods for java.
@@ -69,10 +73,10 @@

Putting the "Ex" in "Experimental": promoted or deleted experimental features.

- <@main.feature title="@Value: promoted" code="/features/Value"> + <@main.feature title="@Value: promoted" href="../Value"> @Value has proven its value and has been moved to the main package. - <@main.feature title="@Builder: promoted" code="/features/Builder"> + <@main.feature title="@Builder: promoted" href="../Builder"> @Builder is a solid base to build APIs on, and has been moved to the main package.
diff --git a/website2/templates/features/experimental/onX.html b/website2/templates/features/experimental/onX.html index 7398ce70..8e07f0ac 100644 --- a/website2/templates/features/experimental/onX.html +++ b/website2/templates/features/experimental/onX.html @@ -9,7 +9,8 @@ <@f.experimental>
- <@main.feature title="val" code="val"> + <@main.feature title="val" href="val"> Finally! Hassle-free final local variables. - <@main.feature title="@NonNull" code="non-null"> + <@main.feature title="@NonNull" href="NonNull"> or: How I learned to stop worrying and love the NullPointerException. - <@main.feature title="@Cleanup" code="cleanup"> + <@main.feature title="@Cleanup" href="Cleanup"> Automatic resource management: Call your close() methods safely with no hassle. - <@main.feature title="@Getter/@Setter" code="getter-setter"> + <@main.feature title="@Getter/@Setter" href="GetterSetter"> Never write public int getFoo() {return foo;} again. - <@main.feature title="@ToString" code="to-string"> + <@main.feature title="@ToString" href="ToString"> No need to start a debugger to see your fields: Just let lombok generate a toString for you! - <@main.feature title="@EqualsAndHashCode" code="equals-and-hashcode"> + <@main.feature title="@EqualsAndHashCode" href="EqualsAndHashCode"> Equality made easy: Generates hashCode and equals implementations from the fields of your object.. - <@main.feature title="@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor" code="constructor"> + <@main.feature title="@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor" href="constructor"> Constructors made to order: Generates constructors that take no arguments, one argument per final / non-nullfield, or one argument for every field. - <@main.feature title="@Data" code="data"> + <@main.feature title="@Data" href="Data"> All together now: A shortcut for @ToString, @EqualsAndHashCode, @Getter on all fields, and @Setter on all non-final fields, and @RequiredArgsConstructor! - <@main.feature title="@Value" code="value"> + <@main.feature title="@Value" href="Value"> Immutable classes made very easy. - <@main.feature title="@Builder" code="builder"> + <@main.feature title="@Builder" href="Builder"> ... and Bob's your uncle: No-hassle fancy-pants APIs for object creation! - <@main.feature title="@SneakyThrows" code="sneaky-throws"> + <@main.feature title="@SneakyThrows" href="SneakyThrows"> To boldly throw checked exceptions where no one has thrown them before! - <@main.feature title="@Synchronized" code="sync"> + <@main.feature title="@Synchronized" href="Synchronized"> synchronized done right: Don't expose your locks. - <@main.feature title="@Getter(lazy=true)" code="getter-lazy"> + <@main.feature title="@Getter(lazy=true)" href="GetterLazy"> Laziness is a virtue! - <@main.feature title="@Log" code="log"> + <@main.feature title="@Log" href="log"> Captain's Log, stardate 24435.7: "What was that line again?"
@@ -72,7 +72,7 @@

Configuration system

- Lombok, made to order: Configure lombok features in one place for your entire project or even your workspace. + Lombok, made to order: Configure lombok features in one place for your entire project or even your workspace.
@@ -80,7 +80,7 @@

Running delombok

- Delombok copies your source files to another directory, replacing all lombok annotations with their desugared form. So, it'll turn @Getter back into the actual getter. It then removes the annotation. This is useful for all sorts of reasons; you can check out what's happening under the hood, if the unthinkable happens and you want to stop using lombok, you can easily remove all traces of it in your source, and you can use delombok to preprocess your source files for source-level tools such as javadoc and GWT. More information about how to run delombok, including instructions for build tools can be found at the delombok page. + Delombok copies your source files to another directory, replacing all lombok annotations with their desugared form. So, it'll turn @Getter back into the actual getter. It then removes the annotation. This is useful for all sorts of reasons; you can check out what's happening under the hood, if the unthinkable happens and you want to stop using lombok, you can easily remove all traces of it in your source, and you can use delombok to preprocess your source files for source-level tools such as javadoc and GWT. More information about how to run delombok, including instructions for build tools can be found at the delombok page.
diff --git a/website2/templates/features/log.html b/website2/templates/features/log.html index e27481b8..2854e896 100644 --- a/website2/templates/features/log.html +++ b/website2/templates/features/log.html @@ -13,12 +13,16 @@

You put the variant of @Log on your class (whichever one applies to the logging system you use); you then have a static final log field, initialized to the name of your class, which you can then use to write log statements.

- There are six choices available:
+ There are several choices available:

@CommonsLog
Creates private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LogExample.class); +
+ @JBossLog +
+ Creates private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LogExample.class);
@Log
@@ -69,6 +73,10 @@ lombok.log.javaUtilLogging.flagUsage = [warning | error] (default: not set)
Lombok will flag any usage of @lombok.extern.java.Log as a warning or error if configured. +
+ lombok.log.jbosslog.flagUsage = [warning | error] (default: not set) +
+ Lombok will flag any usage of @lombok.extern.jbosslog.JBossLog as a warning or error if configured.
lombok.log.log4j.flagUsage = [warning | error] (default: not set)
diff --git a/website2/templates/features/val.html b/website2/templates/features/val.html index 34a3f187..32a8ffdf 100644 --- a/website2/templates/features/val.html +++ b/website2/templates/features/val.html @@ -1,9 +1,14 @@ <#import "_features.html" as f> <@f.scaffold title="val" logline="Finally! Hassle-free final local variables."> + <@f.history> +

+ val was introduced in lombok 0.10. +

+ <@f.overview>

- NEW in Lombok 0.10: You can use val as the type of a local variable declaration instead of actually writing the type. When you do this, the type will be inferred from the initializer expression. The local variable will also be made final. This feature works on local variables and on foreach loops only, not on fields. The initializer expression is required. + You can use val as the type of a local variable declaration instead of actually writing the type. When you do this, the type will be inferred from the initializer expression. The local variable will also be made final. This feature works on local variables and on foreach loops only, not on fields. The initializer expression is required.

val is actually a 'type' of sorts, and exists as a real class in the lombok package. You must import it for val to work (or use lombok.val as the type). The existence of this type on a local variable declaration triggers both the adding of the final keyword as well as copying the type of the initializing expression which overwrites the 'fake' val type.

diff --git a/website2/templates/features/value.html b/website2/templates/features/value.html index d9ea1ca7..fdad0e12 100644 --- a/website2/templates/features/value.html +++ b/website2/templates/features/value.html @@ -17,8 +17,8 @@

In practice, @Value is shorthand for: final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter, except that explicitly including an implementation of any of the relevant methods simply means that part won't be generated and no warning will be emitted. For example, if you write your own toString, no error occurs, and lombok will not generate a toString. Also, any explicit constructor, no matter the arguments list, implies lombok will not generate a constructor. If you do want lombok to generate the all-args constructor, add @AllArgsConstructor to the class. You can mark any constructor or method with @lombok.experimental.Tolerate to hide them from lombok.

- It is possible to override the final-by-default and private-by-default behaviour using either an explicit access level on a field, or by using the @NonFinal or @PackagePrivate annotations.
- It is possible to override any default behaviour for any of the 'parts' that make up @Value by explicitly using that annotation. + It is possible to override the final-by-default and private-by-default behavior using either an explicit access level on a field, or by using the @NonFinal or @PackagePrivate annotations.
+ It is possible to override any default behavior for any of the 'parts' that make up @Value by explicitly using that annotation.

-- cgit