@FieldDefaults was introduced as experimental feature in lombok v0.11.4.
Experimental because:
The @FieldDefaults
annotation can add an access modifier (public
, private
, or protected
)
to each field in the annotated class or enum. It can also add final
to each field in the annotated class or enum.
To add final
to each field, use @FieldDefaults(makeFinal=true)
. Any non-final field which must remain nonfinal
can be annotated with @NonFinal
(also in the lombok.experimental
package).
To add an access modifier to each field, use @FieldDefaults(level=AccessLevel.PRIVATE)
. Any field that does not already have an
access modifier (i.e. any field that looks like package private access) is changed to have the appropriate access modifier. Any package private
field which must remain package private can be annotated with @PackagePrivate
(also in the lombok.experimental
package).
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.