@ SuppressWarnings ( "unchecked" ) public void setHeaders ( final Map < String , Object > headers ) { this . headers . clear ( ) ; for ( Map . Entry < String , Object > entry : headers . entrySet ( ) ) { if ( entry . getValue ( ) instanceof List ) { List value = ( List ) entry . getValue ( ) ; // verify they are all strings for ( Object o : value ) { Assert . isTrue ( o instanceof String , o + " is not a string it is a: '" + o . getClass ( ) + "'" ) ; } this . headers . put ( entry . getKey ( ) , ( List < String > ) entry . getValue ( ) ) ; } else if ( entry . getValue ( ) instanceof String ) { final List < String > value = Collections . singletonList ( ( String ) entry . getValue ( ) ) ; this . headers . put ( entry . getKey ( ) , value ) ; } else { throw new IllegalArgumentException ( "Only strings and list of strings may be headers" ) ; } } }
A map of the header key value pairs . Keys are strings and values are either list of strings or a string .