src/jdk.internal.opt/share/classes/jdk/internal/joptsimple/OptionalArgumentOptionSpec.java
changeset 50428 8c88df2e8a78
parent 47216 71c04702a3d5
equal deleted inserted replaced
50427:b06f330492cd 50428:8c88df2e8a78
    29  * However, the following notice accompanied the original version of this
    29  * However, the following notice accompanied the original version of this
    30  * file:
    30  * file:
    31  *
    31  *
    32  * The MIT License
    32  * The MIT License
    33  *
    33  *
    34  * Copyright (c) 2004-2014 Paul R. Holser, Jr.
    34  * Copyright (c) 2004-2015 Paul R. Holser, Jr.
    35  *
    35  *
    36  * Permission is hereby granted, free of charge, to any person obtaining
    36  * Permission is hereby granted, free of charge, to any person obtaining
    37  * a copy of this software and associated documentation files (the
    37  * a copy of this software and associated documentation files (the
    38  * "Software"), to deal in the Software without restriction, including
    38  * "Software"), to deal in the Software without restriction, including
    39  * without limitation the rights to use, copy, modify, merge, publish,
    39  * without limitation the rights to use, copy, modify, merge, publish,
    53  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    53  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    54  */
    54  */
    55 
    55 
    56 package jdk.internal.joptsimple;
    56 package jdk.internal.joptsimple;
    57 
    57 
    58 import java.util.Collection;
    58 import java.util.List;
    59 
    59 
    60 /**
    60 /**
    61  * Specification of an option that accepts an optional argument.
    61  * Specification of an option that accepts an optional argument.
    62  *
    62  *
    63  * @param <V> represents the type of the arguments this option accepts
    63  * @param <V> represents the type of the arguments this option accepts
    66 class OptionalArgumentOptionSpec<V> extends ArgumentAcceptingOptionSpec<V> {
    66 class OptionalArgumentOptionSpec<V> extends ArgumentAcceptingOptionSpec<V> {
    67     OptionalArgumentOptionSpec( String option ) {
    67     OptionalArgumentOptionSpec( String option ) {
    68         super( option, false );
    68         super( option, false );
    69     }
    69     }
    70 
    70 
    71     OptionalArgumentOptionSpec( Collection<String> options, String description ) {
    71     OptionalArgumentOptionSpec( List<String> options, String description ) {
    72         super( options, false, description );
    72         super( options, false, description );
    73     }
    73     }
    74 
    74 
    75     @Override
    75     @Override
    76     protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) {
    76     protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) {
    77         if ( arguments.hasMore() ) {
    77         if ( arguments.hasMore() ) {
    78             String nextArgument = arguments.peek();
    78             String nextArgument = arguments.peek();
    79 
    79 
    80             if ( !parser.looksLikeAnOption( nextArgument ) )
    80             if ( !parser.looksLikeAnOption( nextArgument ) && canConvertArgument( nextArgument ) )
    81                 handleOptionArgument( parser, detectedOptions, arguments );
    81                 handleOptionArgument( parser, detectedOptions, arguments );
    82             else if ( isArgumentOfNumberType() && canConvertArgument( nextArgument ) )
    82             else if ( isArgumentOfNumberType() && canConvertArgument( nextArgument ) )
    83                 addArguments( detectedOptions, arguments.next() );
    83                 addArguments( detectedOptions, arguments.next() );
    84             else
    84             else
    85                 detectedOptions.add( this );
    85                 detectedOptions.add( this );