Skip to content

Commit 591af95

Browse files
committed
Added setter for Builder.option apache#33.
- Rename new method - Add missing @SInCE tag to new method. - Sort new members.
1 parent c886434 commit 591af95

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
<action type="add" dev="ggregory" due-to="Alex Nordlund" issue="CLI-282">
6161
TypeHandler should throw ParseException for an unsupported class.
6262
</action>
63+
<action type="add" dev="ggregory" due-to="waso, Gary Gregory">
64+
Added setter for Builder.option #33.
65+
</action>
6366
<!-- UPDATE -->
6467
<action type="update" dev="ggregory" issue="CLI-294">
6568
Update Java from version 5 to 7.

src/main/java/org/apache/commons/cli/Option.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@ private Builder(final String option) throws IllegalArgumentException {
8787
this.option = OptionValidator.validate(option);
8888
}
8989

90-
/**
91-
* Sets the name of the Option.
92-
*
93-
* @param opt the name of the Option
94-
* @return this builder, to allow method chaining
95-
* @throws IllegalArgumentException if there are any non valid Option characters in {@code opt}
96-
*/
97-
public Builder opt(String opt) throws IllegalArgumentException {
98-
this.option = OptionValidator.validate(opt);
99-
return this;
100-
}
101-
10290
/**
10391
* Sets the display name for the argument value.
10492
*
@@ -187,6 +175,19 @@ public Builder numberOfArgs(final int numberOfArgs) {
187175
return this;
188176
}
189177

178+
/**
179+
* Sets the name of the Option.
180+
*
181+
* @param option the name of the Option
182+
* @return this builder, to allow method chaining
183+
* @throws IllegalArgumentException if there are any non valid Option characters in {@code opt}
184+
* @since 1.5
185+
*/
186+
public Builder option(String option) throws IllegalArgumentException {
187+
this.option = OptionValidator.validate(option);
188+
return this;
189+
}
190+
190191
/**
191192
* Sets whether the Option can have an optional argument.
192193
*

src/test/java/org/apache/commons/cli/OptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void testBuilderMethods() {
109109
String.class);
110110
checkOption(Option.builder("a").desc("desc").type(Integer.class).build(), "a", "desc", null, Option.UNINITIALIZED, null, false, false, defaultSeparator,
111111
Integer.class);
112-
checkOption(Option.builder().opt("a").desc("desc").type(Integer.class).build(), "a", "desc", null, Option.UNINITIALIZED, null, false, false,
112+
checkOption(Option.builder().option("a").desc("desc").type(Integer.class).build(), "a", "desc", null, Option.UNINITIALIZED, null, false, false,
113113
defaultSeparator, Integer.class);
114114
}
115115

0 commit comments

Comments
 (0)