This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-rewriter.git
The following commit(s) were added to refs/heads/master by this push:
new a557549 SLING-12227 : Status printer does not properly display array
values
a557549 is described below
commit a557549c07324aa0ec5797aba8181ade51731888
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Mon Jan 15 09:18:54 2024 +0100
SLING-12227 : Status printer does not properly display array values
---
.../impl/ProcessingComponentConfigurationImpl.java | 47 ++++++++++++----------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git
a/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
b/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
index ff234f5..5d15304 100644
---
a/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
+++
b/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
@@ -17,6 +17,7 @@
package org.apache.sling.rewriter.impl;
import java.io.PrintWriter;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -41,8 +42,6 @@ public class ProcessingComponentConfigurationImpl implements
ProcessingComponent
/** The configuration map. */
private final ValueMap configuration;
- private final String descText;
-
/**
* Create a new configuration.
* @param type The type of the component.
@@ -50,18 +49,8 @@ public class ProcessingComponentConfigurationImpl implements
ProcessingComponent
*/
public ProcessingComponentConfigurationImpl(final String type, final
ValueMap config) {
this.type = type;
- this.configuration = (config == null ? EMPTY_CONFIG : config);
- final StringBuilder sb = new StringBuilder();
- sb.append("Config(type=");
- sb.append(this.type);
- sb.append(", config=");
- if ( config == null ) {
- sb.append("{}");
- } else {
- sb.append(config);
- }
- sb.append(")");
- this.descText = sb.toString();
+ this.configuration = (config == null ? EMPTY_CONFIG : new
ValueMapDecorator(new HashMap<>(config)));
+ this.configuration.remove("jcr:primaryType");
}
/**
@@ -78,20 +67,36 @@ public class ProcessingComponentConfigurationImpl
implements ProcessingComponent
return this.type;
}
+ private String getConfigurationString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append('{');
+ for(final Map.Entry<String, Object> entry :
this.configuration.entrySet()) {
+ if (sb.length() > 1) {
+ sb.append(", ");
+ }
+ sb.append(entry.getKey());
+ sb.append('=');
+ if (entry.getValue().getClass().isArray()) {
+ sb.append(Arrays.toString((Object[])entry.getValue()));
+ } else {
+ sb.append(entry.getValue());
+ }
+ }
+ sb.append('}');
+ return sb.toString();
+ }
+
@Override
public String toString() {
- return this.descText;
+ return "Config(type=".concat(this.type).concat(",
config=").concat(this.getConfigurationString()).concat(")");
}
void printConfiguration(final PrintWriter pw) {
pw.print(this.type);
- if ( this.configuration == EMPTY_CONFIG ) {
- pw.println();
- } else {
+ if (!this.configuration.isEmpty()) {
pw.print(" : ");
- final Map<String, Object> map = new HashMap<String,
Object>(this.configuration);
- map.remove("jcr:primaryType");
- pw.println(map);
+ pw.print(this.getConfigurationString());
}
+ pw.println();
}
}