You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/org/apache/commons/cli/Option.java
+49-43Lines changed: 49 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -25,16 +25,13 @@ Licensed to the Apache Software Foundation (ASF) under one or more
25
25
importjava.util.Objects;
26
26
27
27
/**
28
-
* Describes a single command-line option. It maintains information regarding the short-name of the option, the
29
-
* long-name, if any exists, a flag indicating if an argument is required for this option, and a self-documenting
30
-
* description of the option.
28
+
* Describes a single command-line option. It maintains information regarding the short-name of the option, the long-name, if any exists, a flag indicating if
29
+
* an argument is required for this option, and a self-documenting description of the option.
31
30
* <p>
32
-
* An Option is not created independently, but is created through an instance of {@link Options}. An Option is required
33
-
* to have at least a short or a long-name.
31
+
* An Option is not created independently, but is created through an instance of {@link Options}. An Option is required to have at least a short or a long-name.
34
32
* </p>
35
33
* <p>
36
-
* <b>Note:</b> once an {@link Option} has been added to an instance of {@link Options}, its required flag cannot be
37
-
* changed.
34
+
* <b>Note:</b> once an {@link Option} has been added to an instance of {@link Options}, its required flag cannot be changed.
38
35
* </p>
39
36
*
40
37
* @see org.apache.commons.cli.Options
@@ -126,7 +123,9 @@ public Option build() {
126
123
/**
127
124
* Sets the converter for the option.
128
125
*
129
-
* <p>Note: see {@link TypeHandler} for serialization discussion.</p>
126
+
* <p>
127
+
* Note: see {@link TypeHandler} for serialization discussion.
128
+
* </p>
130
129
*
131
130
* @param converter the Converter to use.
132
131
* @return this builder, to allow method chaining.
@@ -300,7 +299,7 @@ public Builder valueSeparator() {
* Creates an Option using the specified parameters.
416
415
*
417
-
* @param option short representation of the option.
418
-
* @param hasArg specifies whether the Option takes an argument or not.
416
+
* @param option short representation of the option.
417
+
* @param hasArg specifies whether the Option takes an argument or not.
419
418
* @param description describes the function of the option.
420
419
*
421
420
* @throws IllegalArgumentException if there are any non valid Option characters in {@code opt}.
@@ -427,7 +426,7 @@ public Option(final String option, final boolean hasArg, final String descriptio
427
426
/**
428
427
* Creates an Option using the specified parameters. The option does not take an argument.
429
428
*
430
-
* @param option short representation of the option.
429
+
* @param option short representation of the option.
431
430
* @param description describes the function of the option.
432
431
*
433
432
* @throws IllegalArgumentException if there are any non valid Option characters in {@code opt}.
@@ -439,9 +438,9 @@ public Option(final String option, final String description) throws IllegalArgum
439
438
/**
440
439
* Creates an Option using the specified parameters.
441
440
*
442
-
* @param option short representation of the option.
443
-
* @param longOption the long representation of the option.
444
-
* @param hasArg specifies whether the Option takes an argument or not.
441
+
* @param option short representation of the option.
442
+
* @param longOption the long representation of the option.
443
+
* @param hasArg specifies whether the Option takes an argument or not.
445
444
* @param description describes the function of the option.
446
445
*
447
446
* @throws IllegalArgumentException if there are any non valid Option characters in {@code opt}.
@@ -469,8 +468,8 @@ boolean acceptsArg() {
469
468
}
470
469
471
470
/**
472
-
* Adds the value to this Option. If the number of arguments is greater than zero and there is enough space in the list
473
-
* then add the value. Otherwise, throw a runtime exception.
471
+
* Adds the value to this Option. If the number of arguments is greater than zero and there is enough space in the list then add the value. Otherwise, throw
472
+
* a runtime exception.
474
473
*
475
474
* @param value The value to be added to this Option.
* This method is not intended to be used. It was a piece of internal API that was made public in 1.0. It currently
489
-
* throws an UnsupportedOperationException.
487
+
* This method is not intended to be used. It was a piece of internal API that was made public in 1.0. It currently throws an UnsupportedOperationException.
490
488
*
491
489
* @param value the value to add.
492
490
* @return always throws an {@link UnsupportedOperationException}.
* Gets the number of argument values this Option can take.
567
564
*
568
565
* <p>
569
-
* A value equal to the constant {@link #UNINITIALIZED} (= -1) indicates the number of arguments has not been specified.
570
-
* A value equal to the constant {@link #UNLIMITED_VALUES} (= -2) indicates that this options takes an unlimited amount
571
-
* of values.
566
+
* A value equal to the constant {@link #UNINITIALIZED} (= -1) indicates the number of arguments has not been specified. A value equal to the constant
567
+
* {@link #UNLIMITED_VALUES} (= -2) indicates that this options takes an unlimited amount of values.
572
568
* </p>
573
569
*
574
570
* @return num the number of argument values.
@@ -609,8 +605,7 @@ public String getDescription() {
609
605
}
610
606
611
607
/**
612
-
* Gets the id of this Option. This is only set when the Option shortOpt is a single character. This is used for
613
-
* switch statements.
608
+
* Gets the id of this Option. This is only set when the Option shortOpt is a single character. This is used for switch statements.
614
609
*
615
610
* @return the id of this Option.
616
611
*/
@@ -619,8 +614,7 @@ public int getId() {
619
614
}
620
615
621
616
/**
622
-
* Gets the 'unique' Option identifier. This is the option value if set or the long value
623
-
* if the options value is not set.
617
+
* Gets the 'unique' Option identifier. This is the option value if set or the long value if the options value is not set.
624
618
*
625
619
* @return the 'unique' Option identifier.
626
620
* @since 1.7.0
@@ -642,8 +636,8 @@ public String getLongOpt() {
642
636
/**
643
637
* Gets the name of this Option.
644
638
*
645
-
* It is this String which can be used with {@link CommandLine#hasOption(String opt)} and
646
-
* {@link CommandLine#getOptionValue(String opt)} to check for existence and argument.
639
+
* It is this String which can be used with {@link CommandLine#hasOption(String opt)} and {@link CommandLine#getOptionValue(String opt)} to check for
640
+
* existence and argument.
647
641
*
648
642
* @return The name of this option.
649
643
*/
@@ -811,9 +805,8 @@ public boolean isRequired() {
811
805
}
812
806
813
807
/**
814
-
* Processes the value. If this Option has a value separator the value will have to be parsed into individual tokens.
815
-
* When n-1 tokens have been processed and there are more value separators in the value, parsing is ceased and the
816
-
* remaining characters are added as a single token.
808
+
* Processes the value. If this Option has a value separator the value will have to be parsed into individual tokens. When n-1 tokens have been processed
809
+
* and there are more value separators in the value, parsing is ceased and the remaining characters are added as a single token.
817
810
*
818
811
* @param value The String to be processed.
819
812
*
@@ -945,8 +938,7 @@ public void setType(final Class<?> type) {
945
938
/**
946
939
* Sets the type of this Option.
947
940
* <p>
948
-
* <b>Note:</b> this method is kept for binary compatibility and the input type is supposed to be a {@link Class}
949
-
* object.
941
+
* <b>Note:</b> this method is kept for binary compatibility and the input type is supposed to be a {@link Class} object.
950
942
* </p>
951
943
*
952
944
* @param type the type of this Option.
@@ -966,6 +958,21 @@ public void setValueSeparator(final char sep) {
0 commit comments