Skip to content

Commit 9ed70ef

Browse files
committed
[CLI-230] Options.getRequiredOptions returns now an unmodifiable list.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@1444940 13f79535-47bb-0310-9956-ffa450edef68
1 parent 82e49aa commit 9ed70ef

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<body>
2424

2525
<release version="1.3" date="in SVN">
26+
<action type="fix" dev="tn" issue="CLI-230">
27+
Options.getRequiredOptions() now returns an unmodifiable list.
28+
</action>
2629
<action type="add" dev="tn" issue="CLI-224" due-to="Duncan Jones, Brian Blount">
2730
Added new fluent API to create Option instances via builder class Option.Builder.
2831
This replaces the now deprecated OptionBuilder.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
* if any exists, a flag indicating if an argument is required for
2828
* this option, and a self-documenting description of the option.
2929
* <p>
30-
* An Option is not created independently, but is create through
30+
* An Option is not created independently, but is created through
3131
* an instance of {@link Options}.
32+
* <p>
33+
* <b>Note:</b> once an {@link Option} has been added to an instance
34+
* of {@link Options}, it's required flag may not be changed anymore.
3235
*
3336
* @see org.apache.commons.cli.Options
3437
* @see org.apache.commons.cli.CommandLine

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ List<Option> helpOptions()
197197
/**
198198
* Returns the required options.
199199
*
200-
* @return List of required options
200+
* @return read-only List of required options
201201
*/
202202
public List getRequiredOptions()
203203
{
204-
return requiredOpts;
204+
return Collections.unmodifiableList(requiredOpts);
205205
}
206206

207207
/**

0 commit comments

Comments
 (0)