This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
The following commit(s) were added to refs/heads/master by this push:
new d6d13c51 Normalize builder pattern
d6d13c51 is described below
commit d6d13c51965d50594a2978d13e78ee62293b0508
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Oct 18 08:25:17 2024 -0400
Normalize builder pattern
---
.../apache/commons/cli/help/AbstractHelpFormatter.java | 17 +++++++----------
.../java/org/apache/commons/cli/help/HelpFormatter.java | 2 +-
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git
a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
index ce354ff1..420025f6 100644
--- a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
@@ -183,6 +183,7 @@ public abstract class AbstractHelpFormatter {
* The {@link HelpAppendable} that produces the final output.
*/
protected final HelpAppendable helpAppendable;
+
/**
* The OptionFormatter.Builder used to display options within the help page
*/
@@ -199,17 +200,13 @@ public abstract class AbstractHelpFormatter {
/**
* Constructs the base formatter.
*
- * @param helpAppendable the helpAppendable to output with
- * @param optionFormatBuilder the builder of {@link OptionFormatter} to
format options for display.
- * @param comparator The comparator to use for sorting options.
- * @param optionGroupSeparator the string to separate option groups.
+ * @param builder the builder
*/
- protected AbstractHelpFormatter(final HelpAppendable helpAppendable, final
OptionFormatter.Builder optionFormatBuilder, final Comparator<Option>
comparator,
- final String optionGroupSeparator) {
- this.helpAppendable = Objects.requireNonNull(helpAppendable,
"helpAppendable");
- this.optionFormatBuilder = Objects.requireNonNull(optionFormatBuilder,
"optionFormatBuilder");
- this.comparator = Objects.requireNonNull(comparator, "comparator");
- this.optionGroupSeparator = Util.defaultValue(optionGroupSeparator,
"");
+ protected AbstractHelpFormatter(final Builder<?, ?> builder) {
+ this.helpAppendable =
Objects.requireNonNull(builder.getHelpAppendable(), "helpAppendable");
+ this.optionFormatBuilder =
Objects.requireNonNull(builder.getOptionFormatBuilder(), "optionFormatBuilder");
+ this.comparator = Objects.requireNonNull(builder.getComparator(),
"comparator");
+ this.optionGroupSeparator =
Util.defaultValue(builder.getOptionGroupSeparator(), "");
}
/**
diff --git a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
index 69692dbb..d46245a2 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -129,7 +129,7 @@ public class HelpFormatter extends AbstractHelpFormatter {
* @param builder the Builder to build from.
*/
protected HelpFormatter(final Builder builder) {
- super(builder.getHelpAppendable(), builder.getOptionFormatBuilder(),
builder.getComparator(), builder.getOptionGroupSeparator());
+ super(builder);
this.showSince = builder.showSince;
}