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 specialCharacterMap) { specialCharacterMap.forEach((character, replacement) -> { - property.setDescription(property.getDescription().replace(character, replacement)); - property.setDefaultValue(property.getDefaultValue().replace(character, replacement)); + if (Objects.nonNull(property.getDescription())) + property.setDescription(property.getDescription().replace(character, replacement)); + if (Objects.nonNull(property.getDefaultValue())) + property.setDefaultValue(property.getDefaultValue().replace(character, replacement)); }); } } diff --git a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/project/Project.java b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/project/Project.java index 9d6c59c..74e6c06 100644 --- a/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/project/Project.java +++ b/spring-configuration-property-documenter-core/src/main/java/org/rodnansol/core/project/Project.java @@ -47,7 +47,7 @@ public ProjectType getProjectType() { @Override public String toString() { - return new StringJoiner(", ", Project.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", Project.class.getSimpleName() + "[", "]") .add("basedir=" + basedir) .add("name='" + name + "'") .add("projectType=" + projectType) diff --git a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/AggregationInput.java b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/AggregationInput.java index d40178a..597a423 100644 --- a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/AggregationInput.java +++ b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/AggregationInput.java @@ -145,7 +145,7 @@ public void setIncludedGroups(List includedGroups) { @Override public String toString() { - return new StringJoiner(", ", AggregationInput.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", AggregationInput.class.getSimpleName() + "[", "]") .add("excludedProperties=" + excludedProperties) .add("includedProperties=" + includedProperties) .add("excludedGroups=" + excludedGroups) diff --git a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GenerateAndAggregateDocumentsTask.java b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GenerateAndAggregateDocumentsTask.java index a7cbdc2..84098bf 100644 --- a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GenerateAndAggregateDocumentsTask.java +++ b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GenerateAndAggregateDocumentsTask.java @@ -392,7 +392,7 @@ public void metadata(Closure closure) { @Override public String toString() { - return new StringJoiner(", ", GenerateAndAggregateDocumentsTask.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", GenerateAndAggregateDocumentsTask.class.getSimpleName() + "[", "]") .add("metadataInputs=" + metadataInputs) .add("documentName='" + documentName + "'") .add("documentDescription='" + documentDescription + "'") diff --git a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GeneratePropertyDocumentTask.java b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GeneratePropertyDocumentTask.java index 3161a66..f45a2cd 100644 --- a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GeneratePropertyDocumentTask.java +++ b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/GeneratePropertyDocumentTask.java @@ -373,7 +373,7 @@ public void setFailOnMissingInput(Boolean failOnMissingInput) { @Override public String toString() { - return new StringJoiner(", ", GeneratePropertyDocumentTask.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", GeneratePropertyDocumentTask.class.getSimpleName() + "[", "]") .add("documentName='" + documentName + "'") .add("documentDescription='" + documentDescription + "'") .add("template='" + template + "'") diff --git a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AbstractTemplateCustomization.java b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AbstractTemplateCustomization.java index 9d0b854..b71085d 100644 --- a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AbstractTemplateCustomization.java +++ b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AbstractTemplateCustomization.java @@ -193,7 +193,7 @@ public int hashCode() { @Override public String toString() { - return new StringJoiner(", ", AbstractTemplateCustomization.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", AbstractTemplateCustomization.class.getSimpleName() + "[", "]") .add("tocTitle='" + tocTitle + "'") .add("headerEnabled=" + headerEnabled) .add("tableOfContentsEnabled=" + tableOfContentsEnabled) diff --git a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AsciiDocTemplateCustomization.java b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AsciiDocTemplateCustomization.java index e902555..344dd8f 100644 --- a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AsciiDocTemplateCustomization.java +++ b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/AsciiDocTemplateCustomization.java @@ -65,7 +65,7 @@ public int hashCode() { @Override public String toString() { - return new StringJoiner(", ", AsciiDocTemplateCustomization.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", AsciiDocTemplateCustomization.class.getSimpleName() + "[", "]") .add("tocPlacement=" + tocPlacement) .add("tocLevels=" + tocLevels) .add("tocTitle='" + tocTitle + "'") diff --git a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/HtmlTemplateCustomization.java b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/HtmlTemplateCustomization.java index d108481..43ff69f 100644 --- a/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/HtmlTemplateCustomization.java +++ b/spring-configuration-property-documenter-gradle-plugin/src/main/java/org/rodnansol/gradle/tasks/customization/HtmlTemplateCustomization.java @@ -153,7 +153,7 @@ public int hashCode() { @Override public String toString() { - return new StringJoiner(", ", HtmlTemplateCustomization.class.getSimpleName() + "[", "]") + return new StringJoiner(",\n\t", HtmlTemplateCustomization.class.getSimpleName() + "[", "]") .add("backgroundColor='" + backgroundColor + "'") .add("linkColor='" + linkColor + "'") .add("collapsibleHoverColor='" + collapsibleHoverColor + "'")