@@ -21,41 +21,47 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2121 * Thrown when more than one option in an option group has been provided.
2222 */
2323public class AlreadySelectedException extends ParseException {
24+
2425 /**
2526 * This exception {@code serialVersionUID}.
2627 */
2728 private static final long serialVersionUID = 3674381532418544760L ;
2829
2930 /** The option group selected. */
30- private OptionGroup group ;
31+ private final OptionGroup group ;
3132
3233 /** The option that triggered the exception. */
33- private Option option ;
34+ private final Option option ;
3435
3536 /**
36- * Construct a new {@code AlreadySelectedException} for the specified option group.
37+ * Constructs a new {@code AlreadySelectedException} for the specified option group.
3738 *
3839 * @param group the option group already selected
3940 * @param option the option that triggered the exception
4041 * @since 1.2
4142 */
4243 public AlreadySelectedException (final OptionGroup group , final Option option ) {
43- this ("The option '" + option .getKey () + "' was specified but an option from this group " + "has already been selected: '" + group .getSelected () + "'" );
44+ this ("The option '" + option .getKey () + "' was specified but an option from this group " + "has already been selected: '" + group .getSelected () + "'" ,
45+ group , option );
46+ }
47+
48+ private AlreadySelectedException (final String message , final OptionGroup group , final Option option ) {
49+ super (message );
4450 this .group = group ;
4551 this .option = option ;
4652 }
4753
4854 /**
49- * Construct a new {@code AlreadySelectedException} with the specified detail message.
55+ * Constructs a new {@code AlreadySelectedException} with the specified detail message.
5056 *
5157 * @param message the detail message
5258 */
5359 public AlreadySelectedException (final String message ) {
54- super (message );
60+ this (message , null , null );
5561 }
5662
5763 /**
58- * Returns the option that was added to the group and triggered the exception.
64+ * Gets the option that was added to the group and triggered the exception.
5965 *
6066 * @return the related option
6167 * @since 1.2
@@ -65,7 +71,7 @@ public Option getOption() {
6571 }
6672
6773 /**
68- * Returns the option group where another option has been selected.
74+ * Gets the option group where another option has been selected.
6975 *
7076 * @return the related option group
7177 * @since 1.2
0 commit comments