/**
* Returns the elements of {@code unfiltered} that satisfy a predicate. Thereturned collection is a live view of {@code unfiltered}; changes to one affect the other. <p>The resulting collection's iterator does not support {@code remove()}, but all other collection methods are supported. The collection's {@code add()} and {@code addAll()} methods throw an{@link IllegalArgumentException} if an element that doesn't satisfy thepredicate is provided. When methods such as {@code removeAll()} and{@code clear()} are called on the filtered collection, only elements thatsatisfy the filter will be removed from the underlying collection. <p>The returned collection isn't threadsafe or serializable, even if {@code unfiltered} is.<p>Many of the filtered collection's methods, such as {@code size()}, iterate across every element in the underlying collection and determine which elements satisfy the filter. When a live view is <i>not</i> needed, it may be faster to copy {@code Iterables.filter(unfiltered, predicate)}and use the copy.
*/
public static <E>Collection<E> filter(Collection<E> unfiltered,Predicate<? super E> predicate){
if (unfiltered instanceof FilteredCollection) {
return ((FilteredCollection<E>)unfiltered).createCombined(predicate);
}
return new FilteredCollection<E>(checkNotNull(unfiltered),checkNotNull(predicate));
}

Example 7

From project annotare2, under directory /app/om/src/main/java/uk/ac/ebi/fg/annotare2/dao/dummy/.