File tree Expand file tree Collapse file tree
java/org/apache/commons/cli
test/org/apache/commons/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -401,7 +401,7 @@ public int getArgs()
401401 *
402402 * @param value is a/the value of this Option
403403 */
404- void addValue (String value )
404+ void addValueForProcessing (String value )
405405 {
406406 switch (numberOfArgs )
407407 {
@@ -649,4 +649,11 @@ void clearValues() {
649649 this .values .clear ();
650650 }
651651
652+ public boolean addValue (Object object ) {
653+ throw new UnsupportedOperationException (
654+ "The addValue method is not intended for client use. " +
655+ "Subclasses should use the addValueForProcessing method instead. "
656+ );
657+ }
658+
652659}
Original file line number Diff line number Diff line change @@ -258,7 +258,7 @@ private void processProperties(Properties properties)
258258 {
259259 try
260260 {
261- opt .addValue (value );
261+ opt .addValueForProcessing (value );
262262 }
263263 catch (RuntimeException exp )
264264 {
@@ -340,7 +340,7 @@ public void processArgs(Option opt, ListIterator iter)
340340 // found a value
341341 try
342342 {
343- opt .addValue ( Util .stripLeadingAndTrailingQuotes (str ) );
343+ opt .addValueForProcessing ( Util .stripLeadingAndTrailingQuotes (str ) );
344344 }
345345 catch (RuntimeException exp )
346346 {
Original file line number Diff line number Diff line change 2323 */
2424public class OptionTest extends TestCase {
2525
26+ private static class TestOption extends Option {
27+ public TestOption (String opt , boolean hasArg , String description ) throws IllegalArgumentException {
28+ super (opt , hasArg , description );
29+ }
30+ public boolean addValue (String value ) {
31+ addValueForProcessing (value );
32+ return true ;
33+ }
34+ }
35+
2636 public void testClear () {
27- Option option = new Option ("x" , true , "" );
37+ TestOption option = new TestOption ("x" , true , "" );
2838 assertEquals (0 , option .getValuesList ().size ());
2939 option .addValue ("a" );
3040 assertEquals (1 , option .getValuesList ().size ());
@@ -34,8 +44,8 @@ public void testClear() {
3444
3545 // See http://issues.apache.org/jira/browse/CLI-21
3646 public void testClone () throws CloneNotSupportedException {
37- Option a = new Option ("a" , true , "" );
38- Option b = (Option ) a .clone ();
47+ TestOption a = new TestOption ("a" , true , "" );
48+ TestOption b = (TestOption ) a .clone ();
3949 assertEquals (a , b );
4050 assertNotSame (a , b );
4151 a .setDescription ("a" );
You can’t perform that action at this time.
0 commit comments