private static void addStringList ( CodeBlock . Builder code , List < String > list , String indent ) { int size = list . size ( ) ; code . add ( "$T.asList(\n$L" , Arrays . class , indent ) ; int width = indent . length ( ) ; for ( int i = 0 ; i < size ; i ++ ) { if ( i != 0 ) { code . add ( ", " ) ; width += 2 ; } if ( width > 80 ) { width = indent . length ( ) ; code . add ( "\n$L" , indent ) ; } String element = list . get ( i ) ; code . add ( "$S" , element ) ; width += element . length ( ) + 2 ; } code . add ( "\n$L)" , indent ) ; }
Helper to add a list of strings to a code block .