From 0375f1a9e8f606588d4e136fc718a6876ff0ae4f Mon Sep 17 00:00:00 2001
From: Thomas Klambauer
Note, to tell the gradle-lombok plugin to use the latest version of lombok, you need to explicitly tell it about the latest version number and the SHA-256. For our current latest version, put this in your build.gradle file:
lombok {
- version = ${version}
+ version = '${version}'
sha256 = ""
}
--
cgit
From e964f5eec6015564d561ad45dc29964b4fc4481e Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot @FieldNameConstants was introduced as experimental feature in lombok v1.16.22. +
+ @FieldNameConstants was redesigned in lombok v1.18.4.
@f.history> @@ -18,11 +20,11 @@ <@f.overview>
- The @FieldNameConstants annotation generates string constants (fields marked public static final, of type java.lang.String) containing the field's name, as a string. This is useful for various marshalling and serialization frameworks. The constant field by default is named FIELD_NAME_OF_FIELD, where NAME_OF_FIELD is the same name as the field it represents, except with all uppercase letters, with underscores in front of the uppercase letters in the original field. The prefix (and suffix) is configurable on the @FieldNameConstants annotation.
+ The @FieldNameConstants annotation generates an inner type which contains 1 constant for each field in your class; either string constants (fields marked public static final, of type java.lang.String) or if you prefer, an enum type with 1 value for each field. @FieldNameConstants is useful for various marshalling and serialization frameworks. The constant field (whether enum value or string constant) always has the exact same name as the field, capitalization and all.
- The public access modifier can be changed via the parameter level = AccessLevel.PACKAGE for example. You can force a field to be skipped by supplying level = AccessLevel.NONE.
+ The generated inner type is by default called Fields and is public. You can modify this via @FieldNameConstants(innerTypeName = "FieldNames", access = AccessLevel.PACKAGE) for example. The default inner type name can also be modified via configuration key lombok.fieldNameConstants.innerTypeName. The generated fields are always public.
- Can be applied to classes (in which case every field gets a constant), or to an individual field.
+ Must be applied to classes (or enums, though you'd rarely want to do that). By default includes all non-transient, non-static fields. You can use @FieldNameConstants.Include in fields + @FieldNameConstants(onlyExplicitlyIncluded = true), or @FieldNameConstants.Exclude for more fine-grained control.
@FieldDefaults as a warning or error if configured.
lombok.fieldNameConstants.prefix = a string (default: 'PREFIX_')
- lombok.fieldNameConstants.suffix = a string (default: '' - the blank string)
+ lombok.fieldNameConstants.innerTypeName = a string (default: 'Fields')
- Like other lombok handlers that touch fields, any field whose name starts with a dollar ($) symbol is skipped entirely. Such a field will not be modified at all. Static fields are also skipped.
+ 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 exampleFieldName into public static final String FIELD_EXAMPLE_FIELD_NAME = "exampleFieldName";. The prefix and suffix (here, FIELD_, 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.
+
+ Any parameters of lombok annotations that take strings need to be supplied actual string literals; you cannot have references to constants like those generated by @FieldNameConstants. If you'd like to use @FieldNameConstants to for example fill in the of and/or exclude parameters of @ToString and similar lombok annotations, use the @ToString.Include / @ToString.Exclude etc system instead; these are described at the feature pages for those features.
- The annotation can itself be used to set prefix/suffix. If you do so, it overrides the lombok.fieldNameConstants.prefix/suffix config key. Example: @FieldNameConstants(prefix = ""): This would generate for field helloWorld a constant named HELLO_WORLD instead of the default FIELD_HELLO_WORLD.
+ Like other lombok handlers that touch fields, any field whose name starts with a dollar ($) symbol is skipped entirely. Such a field will not be modified at all. Static fields are also skipped.
+ You can customize parts of your builder, for example adding another method to the builder class, or annotating a method in the builder class, by making the builder class yourself. Lombok will generate everything that you do not manually add, and put it into this builder class. For example, if you are trying to configure jackson to use a specific subtype for a collection, you can write something like:
+@Value @Builder
+@JsonDeserialize(builder = JacksonExample.JacksonExampleBuilder.class)
+public class JacksonExample {
+ @Singular private List<Foo> foos;
+
+ @JsonPOJOBuilder(withPrefix = "")
+ public static class JacksonExampleBuilder implements JacksonExampleBuilderMeta {
+ }
+
+ private interface JacksonExampleBuilderMeta {
+ @JsonDeserialize(contentAs = FooImpl.class) JacksonExampleBuilder foos(List<? extends Foo> foos)
+ }
+}
++ You can use the edge release also from your build tool using the JitPack repository. +
Cutting edge a bit too gutsy for you? You can grab the stable release instead.
--
cgit
From 42c96d92fd5a9b362eba0ceb75c35da906de130f Mon Sep 17 00:00:00 2001
From: Roel Spilker
- You can use the edge release also from your build tool using the JitPack repository. -
Cutting edge a bit too gutsy for you? You can grab the stable release instead. -- cgit