CollectionUtils { public static <V> void filter( Collection<V> input, Predicate<V> predicate ) { Iterator<V> iterator = input.iterator(); while( iterator.hasNext() ) { V value = iterator.next(); if ( ! predicate.test( value ) ) { iterator.remove(); } } }  static int count( List<T> list, T value ); static void filter( Collection<V> input, Predicate<V> predicate ); static void startsWith( Collection<V> input, final String prefix ); static ImmutableList<V> startingWith( Collection<V> input, final String prefix  ); static List<T> shuffle( List<T> list ); static List<List<T>> group( Collection<T> input, int groupSize ); static List<List<T>> group( Collection<T> input, int groupSize, boolean partial ); static T first( Collection<T> input ); @Nullable static T last( Collection<T> input ); static List<T> head( Collection<T> input, int count ); static List<T> tail( Collection<T> input, int count ); static List<T> sort( Collection<T> input ); static List<T> sort( Collection<T> input, Comparator<T> comparator ); static List<String> strings( Collection<T> input ); static ImmutableList<String> toStrings( Collection<T> input ); static List<T> trim(List<T> list, int count);  }
@Test public void testFilter() throws Exception { Predicate<String> predicate = (String value) -> { return ! value.trim().equals( "" ) && ! value.startsWith( "#" ); }; List<String> test = Lists.newArrayList( "" ); filter( test, predicate ); assertEquals( "[]", test.toString() ); test = Lists.newArrayList( "Hello", "# Really" ); filter( test, predicate ); assertEquals( "[Hello]", test.toString() ); }