ListUtil.java revision e0ae5d7e87b1dd6e789803c1b9615a84bd7488b7
1/* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 6package org.mockito.internal.util.collections; 7 8import java.util.Collection; 9import java.util.LinkedList; 10 11public class ListUtil { 12 13 public static <T> LinkedList<T> filter(Collection<T> collection, Filter<T> filter) { 14 LinkedList<T> filtered = new LinkedList<T>(); 15 for (T t : collection) { 16 if (!filter.isOut(t)) { 17 filtered.add(t); 18 } 19 } 20 return filtered; 21 } 22 23 public static interface Filter<T> { 24 boolean isOut(T object); 25 } 26} 27