@SuppressWarnings({"rawtypes", "unchecked"})
    private void setCollectionValues(
            final CommandLineArgumentParser commandLineArgumentParser,
            final List<String> preprocessedValues) // Note that some of these might be tag surrogates
    {
        final Collection c = (Collection) getArgumentValue();
        if (!commandLineArgumentParser.getAppendToCollectionsParserOption()) {
            // if this is a collection then we only want to clear it once at the beginning, before we
            // process any of the values, unless we're in APPEND_TO_COLLECTIONS mode
            c.clear();
        }

        for (int i = 0; i < preprocessedValues.size(); i++) {
            final String stringValue = preprocessedValues.get(i);
            if (stringValue.equals(NULL_ARGUMENT_STRING)) {
                if (i != 0) {
                    // if a "null" is included that isn't the first value for this option, honor it but warn, since it
                    // will clobber any previously set values, and may indicate an unintentional error on the user's part
                    logger.warn(String.format(
                            "A \"null\" value was detected for an option after values for that option were already set. " +
                                    "Clobbering previously set values for this option: %s.", getArgumentAliasDisplayString()));
                }
                if (!isOptional()) {
                    throw new CommandLineException(
                            String.format("Non \"null\" value must be provided for '%s'", getArgumentAliasDisplayString()));
                }
                c.clear();
            } else {
                // if a collection argument was presented as a tagged argument on the command line, and an expansion
                // file was provided as the value, propagate the tags to each value from the expansion file
                final Pair<String, String> normalizedSurrogatePair = getNormalizedTagValuePair(commandLineArgumentParser, stringValue);
                final List<String> expandedValues = argumentAnnotation.suppressFileExpansion() ?
                        Collections.singletonList(normalizedSurrogatePair.getRight()) :
                        commandLineArgumentParser.expandFromExpansionFile(
                                this,
                                normalizedSurrogatePair.getRight(),
                                preprocessedValues);

                for (final String expandedValue : expandedValues) {
                    final Object actualValue = getValuePopulatedWithTags(
                            normalizedSurrogatePair.getLeft(),
                            expandedValue);
                    checkArgumentRange(actualValue);
                    c.add(actualValue);
                }
            }
        }
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) private void setCollectionValues ( final CommandLineArgumentParser commandLineArgumentParser , final List < String > preprocessedValues ) { final Collection c = ( Collection ) getArgumentValue ( ) ; if ( ! commandLineArgumentParser . getAppendToCollectionsParserOption ( ) ) { c . clear ( ) ; } for ( int i = 0 ; i < preprocessedValues . size ( ) ; i ++ ) { final String stringValue = preprocessedValues . get ( i ) ; if ( stringValue . equals ( NULL_ARGUMENT_STRING ) ) { if ( i != 0 ) { logger . warn ( String . format ( "A \"null\" value was detected for an option after values for that option were already set. " + "Clobbering previously set values for this option: %s." , getArgumentAliasDisplayString ( ) ) ) ; } if ( ! isOptional ( ) ) { throw new CommandLineException ( String . format ( "Non \"null\" value must be provided for '%s'" , getArgumentAliasDisplayString ( ) ) ) ; } c . clear ( ) ; } else { final Pair < String , String > normalizedSurrogatePair = getNormalizedTagValuePair ( commandLineArgumentParser , stringValue ) ; final List < String > expandedValues = argumentAnnotation . suppressFileExpansion ( ) ? Collections . singletonList ( normalizedSurrogatePair . getRight ( ) ) : commandLineArgumentParser . expandFromExpansionFile ( this , normalizedSurrogatePair . getRight ( ) , preprocessedValues ) ; for ( final String expandedValue : expandedValues ) { final Object actualValue = getValuePopulatedWithTags ( normalizedSurrogatePair . getLeft ( ) , expandedValue ) ; checkArgumentRange ( actualValue ) ; c . add ( actualValue ) ; } } } }
surrogate, each instance added to the collection must be populated with any tags and attributes.