static void requireNotMultiValued ( final Set < String > parametersToCheck , final Map parameterMap ) { for ( final String parameterName : parametersToCheck ) { if ( parameterMap . containsKey ( parameterName ) ) { final String [ ] values = ( String [ ] ) parameterMap . get ( parameterName ) ; if ( values . length > 1 ) { throw new IllegalStateException ( "Parameter [" + parameterName + "] had multiple values [" + Arrays . toString ( values ) + "] but at most one value is allowable." ) ; } } } }
For each parameter to check verify that it has zero or one value .