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 591af95 Added setter for Builder.option #33.
591af95 is described below
commit 591af95e0a51d067f69f0ddf1a0ac54ef5c04842
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Oct 20 08:11:13 2021 -0400
Added setter for Builder.option #33.
- Rename new method
- Add missing @since tag to new method.
- Sort new members.
---
src/changes/changes.xml | 3 +++
src/main/java/org/apache/commons/cli/Option.java | 25 +++++++++++-----------
.../java/org/apache/commons/cli/OptionTest.java | 2 +-
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 799eb91..720c416 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,6 +60,9 @@
<action type="add" dev="ggregory" due-to="Alex Nordlund" issue="CLI-282">
TypeHandler should throw ParseException for an unsupported class.
</action>
+ <action type="add" dev="ggregory" due-to="waso, Gary Gregory">
+ Added setter for Builder.option #33.
+ </action>
<!-- UPDATE -->
<action type="update" dev="ggregory" issue="CLI-294">
Update Java from version 5 to 7.
diff --git a/src/main/java/org/apache/commons/cli/Option.java
b/src/main/java/org/apache/commons/cli/Option.java
index dfaff0e..7db0372 100644
--- a/src/main/java/org/apache/commons/cli/Option.java
+++ b/src/main/java/org/apache/commons/cli/Option.java
@@ -88,18 +88,6 @@ public class Option implements Cloneable, Serializable {
}
/**
- * Sets the name of the Option.
- *
- * @param opt the name of the Option
- * @return this builder, to allow method chaining
- * @throws IllegalArgumentException if there are any non valid Option
characters in {@code opt}
- */
- public Builder opt(String opt) throws IllegalArgumentException {
- this.option = OptionValidator.validate(opt);
- return this;
- }
-
- /**
* Sets the display name for the argument value.
*
* @param argName the display name for the argument value.
@@ -188,6 +176,19 @@ public class Option implements Cloneable, Serializable {
}
/**
+ * Sets the name of the Option.
+ *
+ * @param option the name of the Option
+ * @return this builder, to allow method chaining
+ * @throws IllegalArgumentException if there are any non valid Option
characters in {@code opt}
+ * @since 1.5
+ */
+ public Builder option(String option) throws IllegalArgumentException {
+ this.option = OptionValidator.validate(option);
+ return this;
+ }
+
+ /**
* Sets whether the Option can have an optional argument.
*
* @param isOptional specifies whether the Option can have an optional
argument.
diff --git a/src/test/java/org/apache/commons/cli/OptionTest.java
b/src/test/java/org/apache/commons/cli/OptionTest.java
index 21859fe..643cbd9 100644
--- a/src/test/java/org/apache/commons/cli/OptionTest.java
+++ b/src/test/java/org/apache/commons/cli/OptionTest.java
@@ -109,7 +109,7 @@ public class OptionTest {
String.class);
checkOption(Option.builder("a").desc("desc").type(Integer.class).build(), "a",
"desc", null, Option.UNINITIALIZED, null, false, false, defaultSeparator,
Integer.class);
-
checkOption(Option.builder().opt("a").desc("desc").type(Integer.class).build(),
"a", "desc", null, Option.UNINITIALIZED, null, false, false,
+
checkOption(Option.builder().option("a").desc("desc").type(Integer.class).build(),
"a", "desc", null, Option.UNINITIALIZED, null, false, false,
defaultSeparator, Integer.class);
}