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

commit ccebe9023819f3be431bf7cacbcf27321fbefe70
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Oct 18 10:03:04 2024 -0400

    Encapsulate new fields
    
    Javadoc
---
 .../commons/cli/help/AbstractHelpFormatter.java    | 45 +++++++++++++++++-----
 .../org/apache/commons/cli/help/HelpFormatter.java |  2 +-
 2 files changed, 37 insertions(+), 10 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 c62521eb..d5e5ee62 100644
--- a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
@@ -63,7 +63,7 @@ public abstract class AbstractHelpFormatter {
         private String optionGroupSeparator = DEFAULT_OPTION_GROUP_SEPARATOR;
 
         /**
-         * Constructs a new instace.
+         * Constructs a new instance.
          * <p>
          * Sets {@code showSince} to {@code true}.
          * </p>
@@ -180,24 +180,24 @@ public abstract class AbstractHelpFormatter {
     public static final String DEFAULT_SYNTAX_PREFIX = "usage: ";
 
     /** The comparator for sorting {@link Option} collections */
-    protected final Comparator<Option> comparator;
+    private final Comparator<Option> comparator;
     /**
      * The {@link HelpAppendable} that produces the final output.
      */
-    protected final HelpAppendable helpAppendable;
+    private final HelpAppendable helpAppendable;
 
     /**
      * The OptionFormatter.Builder used to display options within the help page
      */
-    protected final OptionFormatter.Builder optionFormatBuilder;
+    private final OptionFormatter.Builder optionFormatBuilder;
 
     /** The separator between {@link OptionGroup} components. */
-    protected final String optionGroupSeparator;
+    private final String optionGroupSeparator;
 
     /**
      * The phrase printed before the syntax line.
      */
-    protected String syntaxPrefix = DEFAULT_SYNTAX_PREFIX;
+    private String syntaxPrefix = DEFAULT_SYNTAX_PREFIX;
 
     /**
      * Constructs the base formatter.
@@ -212,14 +212,32 @@ public abstract class AbstractHelpFormatter {
     }
 
     /**
-     * Gets the comparator used by this HelpFormatter.
+     * Gets the comparator for sorting options.
      *
-     * @return The comparator used by this HelpFormatter.
+     * @return The comparator for sorting options.
      */
-    public Comparator<Option> getComparator() {
+    protected Comparator<Option> getComparator() {
         return comparator;
     }
 
+    /**
+     * Gets the help appendable.
+     *
+     * @return The help appendable.
+     */
+    protected HelpAppendable getHelpAppendable() {
+        return helpAppendable;
+    }
+
+    /**
+     * Gets the option formatter builder.
+     *
+     * @return The option formatter builder.
+     */
+    protected OptionFormatter.Builder getOptionFormatBuilder() {
+        return optionFormatBuilder;
+    }
+
     /**
      * Constructs an {@link OptionFormatter} for the specified {@link Option}.
      *
@@ -230,6 +248,15 @@ public abstract class AbstractHelpFormatter {
         return optionFormatBuilder.build(option);
     }
 
+    /**
+     * Gets the option group separator.
+     *
+     * @return The option group separator.
+     */
+    protected String getOptionGroupSeparator() {
+        return optionGroupSeparator;
+    }
+
     /**
      * Gets the {@link HelpAppendable} associated with this help formatter.
      *
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 86efe246..4eb35314 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -166,7 +166,7 @@ public class HelpFormatter extends AbstractHelpFormatter {
         for (final Option option : options) {
             final List<String> row = new ArrayList<>();
             // create an option formatter to correctly format the parts of the 
option
-            final OptionFormatter formatter = 
optionFormatBuilder.build(option);
+            final OptionFormatter formatter = 
getOptionFormatBuilder().build(option);
             sb.setLength(0);
             // append the opt values.
             sb.append(formatter.getBothOpt());

Reply via email to