Skip to content

Commit ccebe90

Browse files
committed
Encapsulate new fields
Javadoc
1 parent 6ce3fa3 commit ccebe90

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

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

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public abstract static class Builder<B extends Builder<B, T>, T extends Abstract
6363
private String optionGroupSeparator = DEFAULT_OPTION_GROUP_SEPARATOR;
6464

6565
/**
66-
* Constructs a new instace.
66+
* Constructs a new instance.
6767
* <p>
6868
* Sets {@code showSince} to {@code true}.
6969
* </p>
@@ -180,24 +180,24 @@ public B setOptionGroupSeparator(final String optionGroupSeparator) {
180180
public static final String DEFAULT_SYNTAX_PREFIX = "usage: ";
181181

182182
/** The comparator for sorting {@link Option} collections */
183-
protected final Comparator<Option> comparator;
183+
private final Comparator<Option> comparator;
184184
/**
185185
* The {@link HelpAppendable} that produces the final output.
186186
*/
187-
protected final HelpAppendable helpAppendable;
187+
private final HelpAppendable helpAppendable;
188188

189189
/**
190190
* The OptionFormatter.Builder used to display options within the help page
191191
*/
192-
protected final OptionFormatter.Builder optionFormatBuilder;
192+
private final OptionFormatter.Builder optionFormatBuilder;
193193

194194
/** The separator between {@link OptionGroup} components. */
195-
protected final String optionGroupSeparator;
195+
private final String optionGroupSeparator;
196196

197197
/**
198198
* The phrase printed before the syntax line.
199199
*/
200-
protected String syntaxPrefix = DEFAULT_SYNTAX_PREFIX;
200+
private String syntaxPrefix = DEFAULT_SYNTAX_PREFIX;
201201

202202
/**
203203
* Constructs the base formatter.
@@ -212,14 +212,32 @@ protected AbstractHelpFormatter(final Builder<?, ?> builder) {
212212
}
213213

214214
/**
215-
* Gets the comparator used by this HelpFormatter.
215+
* Gets the comparator for sorting options.
216216
*
217-
* @return The comparator used by this HelpFormatter.
217+
* @return The comparator for sorting options.
218218
*/
219-
public Comparator<Option> getComparator() {
219+
protected Comparator<Option> getComparator() {
220220
return comparator;
221221
}
222222

223+
/**
224+
* Gets the help appendable.
225+
*
226+
* @return The help appendable.
227+
*/
228+
protected HelpAppendable getHelpAppendable() {
229+
return helpAppendable;
230+
}
231+
232+
/**
233+
* Gets the option formatter builder.
234+
*
235+
* @return The option formatter builder.
236+
*/
237+
protected OptionFormatter.Builder getOptionFormatBuilder() {
238+
return optionFormatBuilder;
239+
}
240+
223241
/**
224242
* Constructs an {@link OptionFormatter} for the specified {@link Option}.
225243
*
@@ -230,6 +248,15 @@ public final OptionFormatter getOptionFormatter(final Option option) {
230248
return optionFormatBuilder.build(option);
231249
}
232250

251+
/**
252+
* Gets the option group separator.
253+
*
254+
* @return The option group separator.
255+
*/
256+
protected String getOptionGroupSeparator() {
257+
return optionGroupSeparator;
258+
}
259+
233260
/**
234261
* Gets the {@link HelpAppendable} associated with this help formatter.
235262
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public TableDefinition getTableDefinition(final Iterable<Option> options) {
166166
for (final Option option : options) {
167167
final List<String> row = new ArrayList<>();
168168
// create an option formatter to correctly format the parts of the option
169-
final OptionFormatter formatter = optionFormatBuilder.build(option);
169+
final OptionFormatter formatter = getOptionFormatBuilder().build(option);
170170
sb.setLength(0);
171171
// append the opt values.
172172
sb.append(formatter.getBothOpt());

0 commit comments

Comments
 (0)