package ar.com.java.samples.acf;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;

import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

public class CollectionsSamples {

	public static void main(String[] args) {
		
		ArrayList<Integer> list = Lists.newArrayList(1, 2, 3, 3, 3);

		// apache commons
		Collection<Integer> ret = CollectionUtils.select(list, new Predicate() {
			
			@Override
			public boolean evaluate(Object object) {
				return object.equals(3);
			}
		});
		System.out.println(ret);
	
		// guava
		Collection<Integer> ret2 = Collections2.filter(list, new com.google.common.base.Predicate<Integer>() {
			@Override
			public boolean apply(Integer input) {
				return input == 2;
			}
		});
		System.out.println(ret2);
		

		// guava
		Iterable<Integer> ret3 = Iterables.filter(list, new com.google.common.base.Predicate<Integer>() {
			@Override
			public boolean apply(Integer input) {
				return input == 3;
			}
			
		});
		System.out.println(ret3);
	}

}

@@ -1158,14 +1158,274 @@
 (ret3);%0A
+%09%09%0A%09%09Integer ret4 = Iterables.find(list, new com.google.common.base.Predicate%3CInteger%3E() %7B%0A%09%09%09@Override%0A%09%09%09public boolean apply(Integer input) %7B%0A%09%09%09%09System.out.println(%22Evaluate arg %22 + input);%0A%09%09%09%09return input == 3;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D);%0A%09%09System.out.println(ret4);%0A
 %09%7D%0A%0A%7D%0A

Add new sample of collections