StringUtil { public static List<String> trimStringList( List<String> list ) { return list == null ? list : list.stream().map( StringUtils::trimToEmpty ).collect( Collectors.toList() ); } private  StringUtil(); static String[] tokenStringToArray( final String tokenizedString, final String token ); static boolean doesPathContainParentPathSegment( final String path ); static void main( final String[] args ); static boolean isEmpty( final String str ); static String getMapAsPrettyString( final Map map ); static Map<String, String> trimStringMap( Map<String, String> map ); static List<String> trimStringList( List<String> list ); static String trimToEmpty( String string );  }
@Test public void testTrimStringList() { List<String> stringList = new ArrayList<>(); for ( int i = 0; i <= 32; i++ ) { stringList.add( (char) i + "foo" ); } stringList.add( "" ); stringList.add( null ); stringList = StringUtil.trimStringList( stringList ); for ( int i = 0; i <= 32; i++ ) { Assert.assertEquals( stringList.get( i ), "foo" ); } Assert.assertEquals( stringList.get( 33 ), "" ); Assert.assertEquals( stringList.get( 34 ), "" ); Assert.assertEquals( StringUtil.trimStringList( null ), null ); List<String> empty = new ArrayList(); Assert.assertEquals( StringUtil.trimStringList( empty ), empty ); }