Allow listy configuration keys to use = to force a list to a single value

This commit is contained in:
Roel Spilker committed 2026-08-21 01:18:05 +02:00
1 parent 1bcf9ff418
commit 277c7bf34a
7 files changed
+94 -10

No files matched your search

@@ -245,7 +245,8 @@ public class ConfigurationApp extends LombokApp {
} else if (value instanceof List<?>) {
List<?> list = (List<?>)value;
if (list.isEmpty()) out.printf("clear %s%n", key.getKeyName());
for (Object element : list) out.printf("%s += %s%n", key.getKeyName(), element);
else if (list.size() == 1) out.printf("%s = %s%n", key.getKeyName(), list.get(0));
else for (Object element : list) out.printf("%s += %s%n", key.getKeyName(), element);
} else {
out.printf("%s = %s%n", key.getKeyName(), value);
}
@@ -103,10 +103,6 @@ public class ConfigurationParser {
reporter.report(context.description(), "'" + keyName + "' is not a list and doesn't support " + operator + " (only = and clear)", lineNumber, line);
continue;
}
if (operator.equals("=") && type.isList()) {
reporter.report(context.description(), "'" + keyName + "' is a list and cannot be assigned to (use +=, -= and clear instead)", lineNumber, line);
continue;
}
Object value = null;
if (stringValue != null) try {
@@ -119,7 +115,13 @@ public class ConfigurationParser {
if (operator.equals("clear")) {
collector.clear(key, context, lineNumber);
} else if (operator.equals("=")) {
collector.set(key, value, context, lineNumber);
if (type.isList()) {
collector.clear(key, context, lineNumber);
collector.add(key, value, context, lineNumber);
}
else {
collector.set(key, value, context, lineNumber);
}
} else if (operator.equals("+=")) {
collector.add(key, value, context, lineNumber);
} else {
@@ -0,0 +1 @@
lombok.accessors.prefix = r_
@@ -11,7 +11,7 @@ lombok.accessors.chain = false
# 3: lombok.accessors.chain = false
# Strip this field prefix, like 'f' or 'm_', from the names of generated getters, setters, and with-ers.
lombok.accessors.prefix += f
lombok.accessors.prefix = f
# BASE/d1/d11/lombok.config (stopped bubbling):
# 5: lombok.accessors.prefix += f
@@ -28,7 +28,7 @@ clear lombok.anyConstructor.addConstructorProperties
clear lombok.log.fieldName
# Copy these annotations to getters, setters, with methods, builder-setters, etc.
lombok.copyableAnnotations += copy1
lombok.copyableAnnotations = copy1
# BASE/d1/d11/lombok.config (stopped bubbling):
# 7: lombok.copyableAnnotations += copy1
@@ -94,7 +94,80 @@ lombok.anyConstructor.addConstructorProperties = true
clear lombok.log.fieldName
# Copy these annotations to getters, setters, with methods, builder-setters, etc.
lombok.copyableAnnotations += copy2
lombok.copyableAnnotations = copy2
# BASE/d1/d11/lombok.config (stopped bubbling):
# 7: lombok.copyableAnnotations += copy1
#
# BASE/archives/a2.zip!reset.config (imported from BASE/d1/d11/d111/lombok.config:2):
# 1: clear lombok.copyableAnnotations
#
# BASE/d1/d11/d111/lombok.config:
# 5: lombok.copyableAnnotations += copy2
# Generate some style of null annotation for generated code where this is relevant. (default: none).
clear lombok.addNullAnnotations
Configuration for 'BASE/d1/d11/d111/directory/setlist'.
# Emit a warning or error if @Accessors is used.
lombok.accessors.flagUsage = ERROR
# BASE/d1/d11/lombok.config (stopped bubbling):
# 4: lombok.accessors.flagUsage = ERROR
# Generate setters that return 'this' instead of 'void' (default: false).
clear lombok.accessors.chain
# BASE/d1/d11/lombok.config (stopped bubbling):
# 3: lombok.accessors.chain = false
#
# BASE/d1/d11/d111/lombok.config:
# 3: clear lombok.accessors.chain
# Strip this field prefix, like 'f' or 'm_', from the names of generated getters, setters, and with-ers.
lombok.accessors.prefix = r_
# BASE/d1/d11/lombok.config (stopped bubbling):
# 5: lombok.accessors.prefix += f
#
# BASE/e1/environment.config (imported from BASE/d1/d11/d111/import1.config:6):
# 1: lombok.accessors.prefix += e_
#
# BASE/home/home.config (imported from BASE/d1/d11/d111/import1.config:7):
# 1: lombok.accessors.prefix += h_
#
# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
# 8: lombok.accessors.prefix += z_
# 9: lombok.accessors.prefix += f
#
# BASE/d1/d11/d111/lombok.config:
# 4: lombok.accessors.prefix += m_
#
# BASE/d1/d11/d111/directory/lombok.config:
# 1: lombok.accessors.prefix += x_
#
# BASE/d1/d11/d111/directory/setlist/lombok.config:
# 1: clear lombok.accessors.prefix
# 1: lombok.accessors.prefix += r_
# Generate @javax.annotation.Generated on all generated code (default: false). Deprecated, use 'lombok.addJavaxGeneratedAnnotation' instead.
lombok.addGeneratedAnnotation = true
# BASE/archives/a1.jar!d1/include.config (imported from BASE/archives/a1.jar!lombok.config:1) (stopped bubbling):
# 4: lombok.addGeneratedAnnotation = true
# Generate @javax.annotation.Generated on all generated code (default: follow lombok.addGeneratedAnnotation).
lombok.addJavaxGeneratedAnnotation = true
# BASE/archives/a1.jar!d2/include.config (imported from BASE/archives/a1.jar!d1/include.config:1) (stopped bubbling):
# 1: lombok.addJavaxGeneratedAnnotation = true
# Generate @ConstructorProperties for generated constructors (default: false).
lombok.anyConstructor.addConstructorProperties = true
# BASE/archives/a1.jar!lombok.config (imported from BASE/d1/d11/d111/import1.config:4) (stopped bubbling):
# 3: lombok.anyConstructor.addConstructorProperties = true
# Use this name for the generated logger fields (default: 'log').
clear lombok.log.fieldName
# Copy these annotations to getters, setters, with methods, builder-setters, etc.
lombok.copyableAnnotations = copy2
# BASE/d1/d11/lombok.config (stopped bubbling):
# 7: lombok.copyableAnnotations += copy1
#
@@ -45,7 +45,14 @@ public class TestConfiguration {
String baseName = "test/configuration/resource/configurationRoot/";
File directory = new File(baseName);
String normalizedName = new File(directory.getAbsoluteFile().toURI().normalize()).toString().replace('\\', '/') + "/";
Collection<String> paths = Arrays.asList(normalizedName + "d1/d11", normalizedName + "d1/d12", normalizedName + "d1/d11/d111", normalizedName + "d1/d11/d111/f1.txt", normalizedName + "features/annotations");
Collection<String> paths = Arrays.asList(
normalizedName + "d1/d11",
normalizedName + "d1/d12",
normalizedName + "d1/d11/d111",
normalizedName + "d1/d11/d111/f1.txt",
normalizedName + "d1/d11/d111/directory/setlist",
normalizedName + "features/annotations"
);
ByteArrayOutputStream rawOut = new ByteArrayOutputStream();
ByteArrayOutputStream rawErr = new ByteArrayOutputStream();