Skip to content

Commit d6d13c5

Browse files
committed
Normalize builder pattern
1 parent 0faa532 commit d6d13c5

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public B setOptionGroupSeparator(final String optionGroupSeparator) {
183183
* The {@link HelpAppendable} that produces the final output.
184184
*/
185185
protected final HelpAppendable helpAppendable;
186+
186187
/**
187188
* The OptionFormatter.Builder used to display options within the help page
188189
*/
@@ -199,17 +200,13 @@ public B setOptionGroupSeparator(final String optionGroupSeparator) {
199200
/**
200201
* Constructs the base formatter.
201202
*
202-
* @param helpAppendable the helpAppendable to output with
203-
* @param optionFormatBuilder the builder of {@link OptionFormatter} to format options for display.
204-
* @param comparator The comparator to use for sorting options.
205-
* @param optionGroupSeparator the string to separate option groups.
203+
* @param builder the builder
206204
*/
207-
protected AbstractHelpFormatter(final HelpAppendable helpAppendable, final OptionFormatter.Builder optionFormatBuilder, final Comparator<Option> comparator,
208-
final String optionGroupSeparator) {
209-
this.helpAppendable = Objects.requireNonNull(helpAppendable, "helpAppendable");
210-
this.optionFormatBuilder = Objects.requireNonNull(optionFormatBuilder, "optionFormatBuilder");
211-
this.comparator = Objects.requireNonNull(comparator, "comparator");
212-
this.optionGroupSeparator = Util.defaultValue(optionGroupSeparator, "");
205+
protected AbstractHelpFormatter(final Builder<?, ?> builder) {
206+
this.helpAppendable = Objects.requireNonNull(builder.getHelpAppendable(), "helpAppendable");
207+
this.optionFormatBuilder = Objects.requireNonNull(builder.getOptionFormatBuilder(), "optionFormatBuilder");
208+
this.comparator = Objects.requireNonNull(builder.getComparator(), "comparator");
209+
this.optionGroupSeparator = Util.defaultValue(builder.getOptionGroupSeparator(), "");
213210
}
214211

215212
/**

src/main/java/org/apache/commons/cli/help/HelpFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static Builder builder() {
129129
* @param builder the Builder to build from.
130130
*/
131131
protected HelpFormatter(final Builder builder) {
132-
super(builder.getHelpAppendable(), builder.getOptionFormatBuilder(), builder.getComparator(), builder.getOptionGroupSeparator());
132+
super(builder);
133133
this.showSince = builder.showSince;
134134
}
135135

0 commit comments

Comments
 (0)