diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/Property.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/Property.java index 66daa94..1dda194 100644 --- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/Property.java +++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/Property.java @@ -1,9 +1,10 @@ package org.rodnansol.core.generator.template.data; -import com.github.jknack.handlebars.internal.lang3.StringUtils; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.util.Objects; +import java.util.StringJoiner; /** * Class representing a property. @@ -26,18 +27,22 @@ public class Property { /** * Property's key. */ + @Nullable private String key; /** * Property's description if specified. */ + @Nullable private String description; /** * Property's default value if specified. */ + @Nullable private String defaultValue; /** * Property's deprecation. */ + @Nullable private PropertyDeprecation propertyDeprecation; public Property(String fqName, String type) { @@ -47,10 +52,10 @@ public Property(String fqName, String type) { public Property(String fqName, String type, String key, String description, String defaultValue, PropertyDeprecation propertyDeprecation) { this(fqName, type); - this.key = StringUtils.defaultIfBlank(key, ""); - this.description = StringUtils.defaultIfBlank(description, ""); - this.defaultValue = StringUtils.defaultIfBlank(defaultValue, ""); - this.propertyDeprecation = Objects.requireNonNullElse(propertyDeprecation, new PropertyDeprecation()); + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.propertyDeprecation = propertyDeprecation; } /** @@ -64,42 +69,47 @@ public static Builder builder(String fqName, String type) { return new Builder(fqName, type); } + @Nullable public String getKey() { return key; } - public void setKey(String key) { + public void setKey(@Nullable String key) { this.key = key; } + @Nullable public String getDescription() { return description; } - public void setDescription(String description) { + public void setDescription(@Nullable String description) { this.description = description; } + @Nullable public String getDefaultValue() { return defaultValue; } - public void setDefaultValue(String defaultValue) { + public void setDefaultValue(@Nullable String defaultValue) { this.defaultValue = defaultValue; } + @NonNull public String getType() { return type; } + @Nullable public PropertyDeprecation getPropertyDeprecation() { return propertyDeprecation; } - public void setPropertyDeprecation(PropertyDeprecation propertyDeprecation) { + public void setPropertyDeprecation(@Nullable PropertyDeprecation propertyDeprecation) { this.propertyDeprecation = propertyDeprecation; } - + @NonNull public String getFqName() { return fqName; } @@ -119,14 +129,14 @@ public int hashCode() { @Override public String toString() { - return "Property{" + - "fqName='" + fqName + '\'' + - ", type='" + type + '\'' + - ", key='" + key + '\'' + - ", description='" + description + '\'' + - ", defaultValue='" + defaultValue + '\'' + - ", propertyDeprecation=" + propertyDeprecation + - '}'; + return new StringJoiner(",\n\t", Property.class.getSimpleName() + "[", "]") + .add("fqName='" + fqName + "'") + .add("type='" + type + "'") + .add("key='" + key + "'") + .add("description='" + description + "'") + .add("defaultValue='" + defaultValue + "'") + .add("propertyDeprecation=" + propertyDeprecation) + .toString(); } public static final class Builder { diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyDeprecation.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyDeprecation.java index 1c661d8..30c4740 100644 --- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyDeprecation.java +++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyDeprecation.java @@ -17,20 +17,17 @@ public class PropertyDeprecation { @Nullable private final String replacement; - public PropertyDeprecation() { - reason = null; - replacement = null; - } - - public PropertyDeprecation(String reason, String replacement) { + public PropertyDeprecation(@Nullable String reason, @Nullable String replacement) { this.reason = reason; this.replacement = replacement; } + @Nullable public String getReason() { return reason; } + @Nullable public String getReplacement() { return replacement; } diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyGroup.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyGroup.java index b6f5bd6..c169e17 100644 --- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyGroup.java +++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/template/data/PropertyGroup.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.StringJoiner; import static org.rodnansol.core.generator.template.data.PropertyGroupConstants.UNKNOWN; import static org.rodnansol.core.generator.template.data.PropertyGroupConstants.UNKNOWN_GROUP; @@ -141,15 +142,15 @@ public PropertyGroup addProperty(Property property) { @Override public String toString() { - return "PropertyGroup{" + - "groupName='" + groupName + '\'' + - ", type='" + type + '\'' + - ", sourceType='" + sourceType + '\'' + - ", properties=" + properties + - ", parentGroup=" + parentGroup + - ", nested=" + nested + - ", unknownGroup=" + unknownGroup + - '}'; + return new StringJoiner(",\n\t", PropertyGroup.class.getSimpleName() + "[", "]") + .add("type='" + type + "'") + .add("sourceType='" + sourceType + "'") + .add("groupName='" + groupName + "'") + .add("properties=" + properties) + .add("parentGroup=" + parentGroup) + .add("nested=" + nested) + .add("unknownGroup=" + unknownGroup) + .toString(); } @Override diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/CustomTemplate.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/CustomTemplate.java index 49767cd..a7a38b5 100644 --- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/CustomTemplate.java +++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/CustomTemplate.java @@ -1,5 +1,7 @@ package org.rodnansol.core.generator.writer; +import java.util.StringJoiner; + /** * Class representing a customization for the templates. *
@@ -46,10 +48,10 @@ public void setCustomFooterTemplate(String customFooterTemplate) {
@Override
public String toString() {
- return "CustomTemplate{" +
- "customHeaderTemplate='" + customHeaderTemplate + '\'' +
- ", customContentTemplate='" + customContentTemplate + '\'' +
- ", customFooterTemplate='" + customFooterTemplate + '\'' +
- '}';
+ return new StringJoiner(",\n\t", CustomTemplate.class.getSimpleName() + "[", "]")
+ .add("customHeaderTemplate='" + customHeaderTemplate + "'")
+ .add("customContentTemplate='" + customContentTemplate + "'")
+ .add("customFooterTemplate='" + customFooterTemplate + "'")
+ .toString();
}
}
diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/PostProcessPropertyGroupsCommand.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/PostProcessPropertyGroupsCommand.java
index 2118c98..a0b00e6 100644
--- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/PostProcessPropertyGroupsCommand.java
+++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/PostProcessPropertyGroupsCommand.java
@@ -5,6 +5,7 @@
import java.util.List;
import java.util.Objects;
+import java.util.StringJoiner;
/**
* Class grouping attributes together that helps to post process the property groups and properties.
@@ -80,13 +81,13 @@ public int hashCode() {
@Override
public String toString() {
- return "PostProcessPropertyGroupsCommand{" +
- "templateCustomization=" + templateCustomization +
- ", propertyGroups=" + propertyGroups +
- ", excludedGroups=" + excludedGroups +
- ", includedGroups=" + includedGroups +
- ", excludedProperties=" + excludedProperties +
- ", includedProperties=" + includedProperties +
- '}';
+ return new StringJoiner(",\n\t", PostProcessPropertyGroupsCommand.class.getSimpleName() + "[", "]")
+ .add("templateCustomization=" + templateCustomization)
+ .add("propertyGroups=" + propertyGroups)
+ .add("excludedGroups=" + excludedGroups)
+ .add("includedGroups=" + includedGroups)
+ .add("excludedProperties=" + excludedProperties)
+ .add("includedProperties=" + includedProperties)
+ .toString();
}
}
diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/SpecialCharacterPostProcessor.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/SpecialCharacterPostProcessor.java
index 48db8dd..d392c44 100644
--- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/SpecialCharacterPostProcessor.java
+++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/generator/writer/postprocess/SpecialCharacterPostProcessor.java
@@ -10,6 +10,7 @@
import org.slf4j.LoggerFactory;
import java.util.Map;
+import java.util.Objects;
import static java.util.Map.entry;
import static java.util.Map.ofEntries;
@@ -62,8 +63,10 @@ public void postProcess(PostProcessPropertyGroupsCommand command) {
private void replaceSpecialCharacters(Property property, Map