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 d78ed6b  Use final.
d78ed6b is described below

commit d78ed6baf1cf85849e2e9ab69115ce73853dc088
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Oct 3 17:36:28 2021 -0400

    Use final.
---
 .../commons/cli/AlreadySelectedException.java      | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/cli/AlreadySelectedException.java 
b/src/main/java/org/apache/commons/cli/AlreadySelectedException.java
index b6ac51a..c2ae5f5 100644
--- a/src/main/java/org/apache/commons/cli/AlreadySelectedException.java
+++ b/src/main/java/org/apache/commons/cli/AlreadySelectedException.java
@@ -21,41 +21,47 @@ package org.apache.commons.cli;
  * Thrown when more than one option in an option group has been provided.
  */
 public class AlreadySelectedException extends ParseException {
+
     /**
      * This exception {@code serialVersionUID}.
      */
     private static final long serialVersionUID = 3674381532418544760L;
 
     /** The option group selected. */
-    private OptionGroup group;
+    private final OptionGroup group;
 
     /** The option that triggered the exception. */
-    private Option option;
+    private final Option option;
 
     /**
-     * Construct a new {@code AlreadySelectedException} for the specified 
option group.
+     * Constructs a new {@code AlreadySelectedException} for the specified 
option group.
      *
      * @param group the option group already selected
      * @param option the option that triggered the exception
      * @since 1.2
      */
     public AlreadySelectedException(final OptionGroup group, final Option 
option) {
-        this("The option '" + option.getKey() + "' was specified but an option 
from this group " + "has already been selected: '" + group.getSelected() + "'");
+        this("The option '" + option.getKey() + "' was specified but an option 
from this group " + "has already been selected: '" + group.getSelected() + "'",
+            group, option);
+    }
+
+    private AlreadySelectedException(final String message, final OptionGroup 
group, final Option option) {
+        super(message);
         this.group = group;
         this.option = option;
     }
 
     /**
-     * Construct a new {@code AlreadySelectedException} with the specified 
detail message.
+     * Constructs a new {@code AlreadySelectedException} with the specified 
detail message.
      *
      * @param message the detail message
      */
     public AlreadySelectedException(final String message) {
-        super(message);
+        this(message, null, null);
     }
 
     /**
-     * Returns the option that was added to the group and triggered the 
exception.
+     * Gets the option that was added to the group and triggered the exception.
      *
      * @return the related option
      * @since 1.2
@@ -65,7 +71,7 @@ public class AlreadySelectedException extends ParseException {
     }
 
     /**
-     * Returns the option group where another option has been selected.
+     * Gets the option group where another option has been selected.
      *
      * @return the related option group
      * @since 1.2

Reply via email to