aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown1
-rw-r--r--src/core/lombok/ConfigurationKeys.java14
-rw-r--r--src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java26
-rw-r--r--src/core/lombok/experimental/FieldNameConstants.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldNameConstants.java26
-rw-r--r--test/transform/resource/after-delombok/FieldNameConstantsBasic.java4
-rw-r--r--test/transform/resource/after-delombok/FieldNameConstantsConfigKeys.java4
-rw-r--r--test/transform/resource/after-delombok/FieldNameConstantsWeird.java2
-rw-r--r--test/transform/resource/after-ecj/FieldNameConstantsBasic.java4
-rw-r--r--test/transform/resource/after-ecj/FieldNameConstantsConfigKeys.java9
-rw-r--r--test/transform/resource/after-ecj/FieldNameConstantsWeird.java6
-rw-r--r--test/transform/resource/before/FieldNameConstantsConfigKeys.java7
-rw-r--r--test/transform/resource/before/FieldNameConstantsWeird.java3
-rw-r--r--test/transform/resource/messages-delombok/FieldNameConstantsWeird.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/FieldNameConstantsWeird.java.messages2
-rw-r--r--website/templates/features/experimental/FieldNameConstants.html14
16 files changed, 97 insertions, 29 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 771ccc55..f1575a53 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -7,6 +7,7 @@ Lombok Changelog
* BUGFIX: Using boolean parameters in lombok annotations would fail. [Issue #1709](https://github.com/rzwitserloot/lombok/issues/1709)
* BUGFIX: Delombok would give an error message. [Issue #1705](https://github.com/rzwitserloot/lombok/issues/1705)
* FEATURE: Google's [Flogger (a.k.a. FluentLogger)](https://google.github.io/flogger/) is now available via `@Flogger`. [Issue #1697](https://github.com/rzwitserloot/lombok/issues/1697)
+* FEATURE: `@FieldNameConstants` has been extended to support prefixes and suffixes. By default, the generated constants are prefixed with `FIELD_`. [Docs on @FieldNameConstants](https://projectlombok.org/features/experimental/FieldNameConstants).
### v1.16.22 "Envious Ferret" (May 29th, 2018)
* FEATURE: Private no-args constructor for `@Data` and `@Value` to enable deserialization frameworks (like Jackson) to operate out-of-the-box. Use `lombok.noArgsConstructor.extraPrivate = false` to disable this behavior.
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java
index adca920e..46c3f770 100644
--- a/src/core/lombok/ConfigurationKeys.java
+++ b/src/core/lombok/ConfigurationKeys.java
@@ -521,6 +521,20 @@ public class ConfigurationKeys {
*/
public static final ConfigurationKey<FlagUsageType> FIELD_NAME_CONSTANTS_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.fieldNameConstants.flagUsage", "Emit a warning or error if @FieldNameConstants is used.") {};
+ /**
+ * lombok configuration: {@code lombok.fieldNameConstants.prefix} = &lt;String: aJavaIdentifierPrefix&gt; (Default: {@code PREFIX_}).
+ *
+ * The names of the constants generated by {@code @FieldNameConstants} will be prefixed with this value.
+ */
+ public static final ConfigurationKey<String> FIELD_NAME_CONSTANTS_PREFIX = new ConfigurationKey<String>("lombok.fieldNameConstants.prefix", "names of constants generated by @FieldNameConstants will be prefixed with this value. (default: 'PREFIX_').") {};
+
+ /**
+ * lombok configuration: {@code lombok.fieldNameConstants.suffix} = &lt;String: aJavaIdentifierPrefix&gt; (Default: nothing).
+ *
+ * The names of the constants generated by {@code @FieldNameConstants} will be suffixed with this value.
+ */
+ public static final ConfigurationKey<String> FIELD_NAME_CONSTANTS_SUFFIX = new ConfigurationKey<String>("lombok.fieldNameConstants.suffix", "names of constants generated by @FieldNameConstants will be suffixed with this value. (default: nothing).") {};
+
// ----- Wither -----
/**
diff --git a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
index 754ddf47..c3a28f7f 100644
--- a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
@@ -49,7 +49,7 @@ import org.mangosdk.spi.ProviderFor;
@ProviderFor(EclipseAnnotationHandler.class)
public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldNameConstants> {
- public void generateFieldNameConstantsForType(EclipseNode typeNode, EclipseNode errorNode, AccessLevel level) {
+ public void generateFieldNameConstantsForType(EclipseNode typeNode, EclipseNode errorNode, AccessLevel level, String prefix, String suffix) {
TypeDeclaration typeDecl = null;
if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
@@ -62,13 +62,13 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
}
for (EclipseNode field : typeNode.down()) {
- if (fieldQualifiesForFieldNameConstantsGeneration(field)) generateFieldNameConstantsForField(field, errorNode.get(), level);
+ if (fieldQualifiesForFieldNameConstantsGeneration(field)) generateFieldNameConstantsForField(field, errorNode.get(), level, prefix, suffix);
}
}
- private void generateFieldNameConstantsForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level) {
+ private void generateFieldNameConstantsForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, String prefix, String suffix) {
if (hasAnnotation(FieldNameConstants.class, fieldNode)) return;
- createFieldNameConstantsForField(level, fieldNode, fieldNode, pos, false);
+ createFieldNameConstantsForField(level, prefix, suffix, fieldNode, fieldNode, pos, false);
}
private boolean fieldQualifiesForFieldNameConstantsGeneration(EclipseNode field) {
@@ -83,27 +83,33 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
EclipseNode node = annotationNode.up();
FieldNameConstants annotatationInstance = annotation.getInstance();
AccessLevel level = annotatationInstance.level();
+ String prefix = annotatationInstance.prefix();
+ String suffix = annotatationInstance.suffix();
+ if (prefix.equals(" CONFIG DEFAULT ")) prefix = annotationNode.getAst().readConfiguration(ConfigurationKeys.FIELD_NAME_CONSTANTS_PREFIX);
+ if (suffix.equals(" CONFIG DEFAULT ")) suffix = annotationNode.getAst().readConfiguration(ConfigurationKeys.FIELD_NAME_CONSTANTS_SUFFIX);
+ if (prefix == null) prefix = "FIELD_";
+ if (suffix == null) suffix = "";
if (node == null) return;
switch (node.getKind()) {
case FIELD:
- if (level != AccessLevel.NONE) createFieldNameConstantsForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true);
+ if (level != AccessLevel.NONE) createFieldNameConstantsForFields(level, prefix, suffix, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true);
break;
case TYPE:
if (level == AccessLevel.NONE) {
annotationNode.addWarning("type-level '@FieldNameConstants' does not work with AccessLevel.NONE.");
return;
}
- generateFieldNameConstantsForType(node, annotationNode, level);
+ generateFieldNameConstantsForType(node, annotationNode, level, prefix, suffix);
break;
}
}
- private void createFieldNameConstantsForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
- for (EclipseNode fieldNode : fieldNodes) createFieldNameConstantsForField(level, fieldNode, errorNode, source, whineIfExists);
+ private void createFieldNameConstantsForFields(AccessLevel level, String prefix, String suffix, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
+ for (EclipseNode fieldNode : fieldNodes) createFieldNameConstantsForField(level, prefix, suffix, fieldNode, errorNode, source, whineIfExists);
}
- private void createFieldNameConstantsForField(AccessLevel level, EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
+ private void createFieldNameConstantsForField(AccessLevel level, String prefix, String suffix, EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
if (fieldNode.getKind() != Kind.FIELD) {
errorNode.addError("@FieldNameConstants is only supported on a class, an enum, or a field");
return;
@@ -111,7 +117,7 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
String fieldName = new String(field.name);
- String constantName = HandlerUtil.camelCaseToConstant(fieldName);
+ String constantName = prefix + HandlerUtil.camelCaseToConstant(fieldName) + suffix;
if (constantName.equals(fieldName)) {
fieldNode.addWarning("Not generating constant for this field: The name of the constant would be equal to the name of this field.");
return;
diff --git a/src/core/lombok/experimental/FieldNameConstants.java b/src/core/lombok/experimental/FieldNameConstants.java
index 41b33ac7..31c2970c 100644
--- a/src/core/lombok/experimental/FieldNameConstants.java
+++ b/src/core/lombok/experimental/FieldNameConstants.java
@@ -35,4 +35,6 @@ import lombok.AccessLevel;
@Retention(RetentionPolicy.SOURCE)
public @interface FieldNameConstants {
lombok.AccessLevel level() default AccessLevel.PUBLIC;
+ String prefix() default " CONFIG DEFAULT ";
+ String suffix() default " CONFIG DEFAULT ";
}
diff --git a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
index 089d225d..8ff136fc 100644
--- a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
@@ -49,7 +49,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@ProviderFor(JavacAnnotationHandler.class)
public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameConstants> {
- public void generateFieldNameConstantsForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level) {
+ public void generateFieldNameConstantsForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, String prefix, String suffix) {
JCClassDecl typeDecl = null;
if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
@@ -62,13 +62,13 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
}
for (JavacNode field : typeNode.down()) {
- if (fieldQualifiesForFieldNameConstantsGeneration(field)) generateFieldNameConstantsForField(field, errorNode.get(), level);
+ if (fieldQualifiesForFieldNameConstantsGeneration(field)) generateFieldNameConstantsForField(field, errorNode.get(), level, prefix, suffix);
}
}
- private void generateFieldNameConstantsForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level) {
+ private void generateFieldNameConstantsForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level, String prefix, String suffix) {
if (hasAnnotation(FieldNameConstants.class, fieldNode)) return;
- createFieldNameConstantsForField(level, fieldNode, fieldNode, false);
+ createFieldNameConstantsForField(level, prefix, suffix, fieldNode, fieldNode, false);
}
private boolean fieldQualifiesForFieldNameConstantsGeneration(JavacNode field) {
@@ -88,26 +88,32 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
JavacNode node = annotationNode.up();
FieldNameConstants annotatationInstance = annotation.getInstance();
AccessLevel level = annotatationInstance.level();
+ String prefix = annotatationInstance.prefix();
+ String suffix = annotatationInstance.suffix();
+ if (prefix.equals(" CONFIG DEFAULT ")) prefix = annotationNode.getAst().readConfiguration(ConfigurationKeys.FIELD_NAME_CONSTANTS_PREFIX);
+ if (suffix.equals(" CONFIG DEFAULT ")) suffix = annotationNode.getAst().readConfiguration(ConfigurationKeys.FIELD_NAME_CONSTANTS_SUFFIX);
+ if (prefix == null) prefix = "FIELD_";
+ if (suffix == null) suffix = "";
if (node == null) return;
switch (node.getKind()) {
case FIELD:
- if (level != AccessLevel.NONE) createFieldNameConstantsForFields(level, fields, annotationNode, annotationNode, true);
+ if (level != AccessLevel.NONE) createFieldNameConstantsForFields(level, prefix, suffix, fields, annotationNode, annotationNode, true);
break;
case TYPE:
if (level == AccessLevel.NONE) {
annotationNode.addWarning("type-level '@FieldNameConstants' does not work with AccessLevel.NONE.");
return;
}
- generateFieldNameConstantsForType(node, annotationNode, level);
+ generateFieldNameConstantsForType(node, annotationNode, level, prefix, suffix);
break;
}
}
- private void createFieldNameConstantsForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode annotationNode, JavacNode errorNode, boolean whineIfExists) {
- for (JavacNode fieldNode : fieldNodes) createFieldNameConstantsForField(level, fieldNode, errorNode, whineIfExists);
+ private void createFieldNameConstantsForFields(AccessLevel level, String prefix, String suffix, Collection<JavacNode> fieldNodes, JavacNode annotationNode, JavacNode errorNode, boolean whineIfExists) {
+ for (JavacNode fieldNode : fieldNodes) createFieldNameConstantsForField(level, prefix, suffix, fieldNode, errorNode, whineIfExists);
}
- private void createFieldNameConstantsForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists) {
+ private void createFieldNameConstantsForField(AccessLevel level, String prefix, String suffix, JavacNode fieldNode, JavacNode source, boolean whineIfExists) {
if (fieldNode.getKind() != Kind.FIELD) {
source.addError("@FieldNameConstants is only supported on a class, an enum, or a field");
return;
@@ -115,7 +121,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
JCVariableDecl field = (JCVariableDecl) fieldNode.get();
String fieldName = field.name.toString();
- String constantName = HandlerUtil.camelCaseToConstant(fieldName);
+ String constantName = prefix + HandlerUtil.camelCaseToConstant(fieldName) + suffix;
if (constantName.equals(fieldName)) {
fieldNode.addWarning("Not generating constant for this field: The name of the constant would be equal to the name of this field.");
return;
diff --git a/test/transform/resource/after-delombok/FieldNameConstantsBasic.java b/test/transform/resource/after-delombok/FieldNameConstantsBasic.java
index de5d68c6..4e547aa5 100644
--- a/test/transform/resource/after-delombok/FieldNameConstantsBasic.java
+++ b/test/transform/resource/after-delombok/FieldNameConstantsBasic.java
@@ -1,6 +1,6 @@
public class FieldNameConstantsBasic {
- protected static final java.lang.String I_AM_A_DVD_PLAYER = "iAmADvdPlayer";
- public static final java.lang.String BUT_PRINT_ME_PLEASE = "butPrintMePlease";
+ protected static final java.lang.String FIELD_I_AM_A_DVD_PLAYER = "iAmADvdPlayer";
+ public static final java.lang.String FIELD_BUT_PRINT_ME_PLEASE = "butPrintMePlease";
String iAmADvdPlayer;
int $skipMe;
static double skipMeToo;
diff --git a/test/transform/resource/after-delombok/FieldNameConstantsConfigKeys.java b/test/transform/resource/after-delombok/FieldNameConstantsConfigKeys.java
new file mode 100644
index 00000000..c71b9264
--- /dev/null
+++ b/test/transform/resource/after-delombok/FieldNameConstantsConfigKeys.java
@@ -0,0 +1,4 @@
+public class FieldNameConstantsConfigKeys {
+ public static final java.lang.String I_AM_A_DVD_PLAYER_SFX = "iAmADvdPlayer";
+ String iAmADvdPlayer;
+}
diff --git a/test/transform/resource/after-delombok/FieldNameConstantsWeird.java b/test/transform/resource/after-delombok/FieldNameConstantsWeird.java
index a256f5ba..6940f628 100644
--- a/test/transform/resource/after-delombok/FieldNameConstantsWeird.java
+++ b/test/transform/resource/after-delombok/FieldNameConstantsWeird.java
@@ -1,4 +1,6 @@
public class FieldNameConstantsWeird {
+ public static final java.lang.String FIELD_AZ = "A";
String iAmADvdPlayer;
String X;
+ String A;
}
diff --git a/test/transform/resource/after-ecj/FieldNameConstantsBasic.java b/test/transform/resource/after-ecj/FieldNameConstantsBasic.java
index bfa339fb..f77203ba 100644
--- a/test/transform/resource/after-ecj/FieldNameConstantsBasic.java
+++ b/test/transform/resource/after-ecj/FieldNameConstantsBasic.java
@@ -1,8 +1,8 @@
import lombok.experimental.FieldNameConstants;
import lombok.AccessLevel;
public @FieldNameConstants class FieldNameConstantsBasic {
- public static final java.lang.String BUT_PRINT_ME_PLEASE = "butPrintMePlease";
- protected static final java.lang.String I_AM_A_DVD_PLAYER = "iAmADvdPlayer";
+ public static final java.lang.String FIELD_BUT_PRINT_ME_PLEASE = "butPrintMePlease";
+ protected static final java.lang.String FIELD_I_AM_A_DVD_PLAYER = "iAmADvdPlayer";
@FieldNameConstants(level = AccessLevel.PROTECTED) String iAmADvdPlayer;
int $skipMe;
static double skipMeToo;
diff --git a/test/transform/resource/after-ecj/FieldNameConstantsConfigKeys.java b/test/transform/resource/after-ecj/FieldNameConstantsConfigKeys.java
new file mode 100644
index 00000000..44629ee5
--- /dev/null
+++ b/test/transform/resource/after-ecj/FieldNameConstantsConfigKeys.java
@@ -0,0 +1,9 @@
+public @lombok.experimental.FieldNameConstants class FieldNameConstantsConfigKeys {
+ public static final java.lang.String I_AM_A_DVD_PLAYER_SFX = "iAmADvdPlayer";
+ String iAmADvdPlayer;
+ <clinit>() {
+ }
+ public FieldNameConstantsConfigKeys() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/FieldNameConstantsWeird.java b/test/transform/resource/after-ecj/FieldNameConstantsWeird.java
index c581b7ef..9958f664 100644
--- a/test/transform/resource/after-ecj/FieldNameConstantsWeird.java
+++ b/test/transform/resource/after-ecj/FieldNameConstantsWeird.java
@@ -1,8 +1,12 @@
import lombok.experimental.FieldNameConstants;
import lombok.AccessLevel;
public @FieldNameConstants class FieldNameConstantsWeird {
+ public static final java.lang.String FIELD_AZ = "A";
@FieldNameConstants(level = AccessLevel.NONE) String iAmADvdPlayer;
- String X;
+ @FieldNameConstants(prefix = "") String X;
+ @FieldNameConstants(suffix = "Z") String A;
+ <clinit>() {
+ }
public FieldNameConstantsWeird() {
super();
}
diff --git a/test/transform/resource/before/FieldNameConstantsConfigKeys.java b/test/transform/resource/before/FieldNameConstantsConfigKeys.java
new file mode 100644
index 00000000..ab8e3091
--- /dev/null
+++ b/test/transform/resource/before/FieldNameConstantsConfigKeys.java
@@ -0,0 +1,7 @@
+//CONF: lombok.fieldNameConstants.prefix =
+//CONF: lombok.fieldNameConstants.suffix = _SFX
+
+@lombok.experimental.FieldNameConstants
+public class FieldNameConstantsConfigKeys {
+ String iAmADvdPlayer;
+}
diff --git a/test/transform/resource/before/FieldNameConstantsWeird.java b/test/transform/resource/before/FieldNameConstantsWeird.java
index 0f99133d..74ec299a 100644
--- a/test/transform/resource/before/FieldNameConstantsWeird.java
+++ b/test/transform/resource/before/FieldNameConstantsWeird.java
@@ -5,5 +5,8 @@ import lombok.AccessLevel;
public class FieldNameConstantsWeird {
@FieldNameConstants(level = AccessLevel.NONE)
String iAmADvdPlayer;
+ @FieldNameConstants(prefix = "")
String X;
+ @FieldNameConstants(suffix = "Z")
+ String A;
}
diff --git a/test/transform/resource/messages-delombok/FieldNameConstantsWeird.java.messages b/test/transform/resource/messages-delombok/FieldNameConstantsWeird.java.messages
index d5fc44f5..02a38d58 100644
--- a/test/transform/resource/messages-delombok/FieldNameConstantsWeird.java.messages
+++ b/test/transform/resource/messages-delombok/FieldNameConstantsWeird.java.messages
@@ -1 +1 @@
-8 Not generating constant for this field: The name of the constant would be equal to the name of this field.
+9 Not generating constant for this field: The name of the constant would be equal to the name of this field.
diff --git a/test/transform/resource/messages-ecj/FieldNameConstantsWeird.java.messages b/test/transform/resource/messages-ecj/FieldNameConstantsWeird.java.messages
index d5fc44f5..02a38d58 100644
--- a/test/transform/resource/messages-ecj/FieldNameConstantsWeird.java.messages
+++ b/test/transform/resource/messages-ecj/FieldNameConstantsWeird.java.messages
@@ -1 +1 @@
-8 Not generating constant for this field: The name of the constant would be equal to the name of this field.
+9 Not generating constant for this field: The name of the constant would be equal to the name of this field.
diff --git a/website/templates/features/experimental/FieldNameConstants.html b/website/templates/features/experimental/FieldNameConstants.html
index 05c57f84..c5e57195 100644
--- a/website/templates/features/experimental/FieldNameConstants.html
+++ b/website/templates/features/experimental/FieldNameConstants.html
@@ -3,7 +3,7 @@
<@f.scaffold title="@FieldNameConstants" logline="Name... that... field! String constants for your field's names.">
<@f.history>
<p>
- @FieldNameConstants was introduced as experimental feature in lombok v2.0.0.
+ @FieldNameConstants was introduced as experimental feature in lombok v1.16.22.
</p>
</@f.history>
@@ -18,7 +18,7 @@
<@f.overview>
<p>
- The <code>@FieldNameConstants</code> annotation generates string constants (fields marked <code>public static final</code>, of type <code>java.lang.String</code>) containing the field's name, as a string. This is useful for various marshalling and serialization frameworks. The constant field has the same as the field it represents, except with all uppercase letters, with underscores in front of the uppercase letters in the original field. If this results in the exact same name, the constant is not generated (a warning is generated instead).
+ The <code>@FieldNameConstants</code> annotation generates string constants (fields marked <code>public static final</code>, of type <code>java.lang.String</code>) containing the field's name, as a string. This is useful for various marshalling and serialization frameworks. The constant field by default is named <code>FIELD_<em>NAME_OF_FIELD</em></code>, where <em>NAME_OF_FIELD</em> 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 <code>@FieldNameConstants</code> annotation.
</p><p>
The <code>public</code> access modifier can be changed via the parameter <code>level = AccessLevel.PACKAGE</code> for example. You can force a field to be skipped by supplying <code>level = AccessLevel.NONE</code>.
</p><p>
@@ -33,12 +33,22 @@
<code>lombok.fieldNameConstants.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
</dt><dd>
Lombok will flag any usage of <code>@FieldDefaults</code> as a warning or error if configured.
+ </dd><dt>
+ <code>lombok.fieldNameConstants.prefix</code> = <em>a string</em> (default: 'PREFIX_')
+ </dt><dd>
+ Lombok will generate the name for each fieldconstant by constant-casing the field name and then prefixing this string to the result.
+ </dd><dt>
+ <code>lombok.fieldNameConstants.suffix</code> = <em>a string</em> (default: '' - the blank string)
+ </dt><dd>
+ Lombok will generate the name for each fieldconstant by constant-casing the field name and then suffixing this string to the result.
</dd>
</@f.confKeys>
<@f.smallPrint>
<p>
Like other lombok handlers that touch fields, any field whose name starts with a dollar (<code>$</code>) symbol is skipped entirely. Such a field will not be modified at all. Static fields are also skipped.
+ </p><p>
+ The annotation can itself be used to set prefix/suffix. If you do so, it overrides the <code>lombok.fieldNameConstants.prefix/suffix</code> config key. Example: <code>@FieldNameConstants(prefix = "")</code>: This would generate for field <code>helloWorld</code> a constant named <code>HELLO_WORLD</code> instead of the default <code>FIELD_HELLO_WORLD</code>.
</p>
</@f.smallPrint>
</@f.scaffold>