private List < NamedArgumentDefinition > validatePluginArgumentValues ( ) { final List < NamedArgumentDefinition > actualArgumentDefinitions = new ArrayList <> ( ) ; for ( final NamedArgumentDefinition argumentDefinition : namedArgumentDefinitions ) { if ( ! argumentDefinition . isControlledByPlugin ( ) ) { actualArgumentDefinitions . add ( argumentDefinition ) ; } else { final boolean isAllowed = argumentDefinition . getDescriptorForControllingPlugin ( ) . isDependentArgumentAllowed ( argumentDefinition . getContainingObject ( ) . getClass ( ) ) ; if ( argumentDefinition . getHasBeenSet ( ) ) { if ( ! isAllowed ) { // dangling dependent argument; a value was specified but it's containing // (predecessor) plugin argument wasn't specified throw new CommandLineException ( String . format ( "Argument \"%s/%s\" is only valid when the argument \"%s\" is specified" , argumentDefinition . getShortName ( ) , argumentDefinition . getLongName ( ) , argumentDefinition . getContainingObject ( ) . getClass ( ) . getSimpleName ( ) ) ) ; } actualArgumentDefinitions . add ( argumentDefinition ) ; } else if ( isAllowed ) { // the predecessor argument was seen, so this value is allowed but hasn't been set; keep the // argument definition to allow validation to check for missing required args actualArgumentDefinitions . add ( argumentDefinition ) ; } } } // finally, give each plugin a chance to trim down any unseen instances from it's own list pluginDescriptors . entrySet ( ) . forEach ( e -> e . getValue ( ) . validateAndResolvePlugins ( ) ) ; // return the updated list of argument definitions with the new list return actualArgumentDefinitions ; }
other arguments that require validation .