Skip to content

Instantly share code, notes, and snippets.

@rgantt
Last active December 29, 2015 04:59
Show Gist options
  • Save rgantt/7618428 to your computer and use it in GitHub Desktop.
Save rgantt/7618428 to your computer and use it in GitHub Desktop.
functional programming fanservice
/**
* FP fanservice
*/
private interface Predicate<T> {
public boolean evaluate(final T item);
}
protected <T> Collection<T> filter(final Collection<T> collection, final Predicate<T> predicate) {
final Collection<T> filtered = new ArrayList<T>();
for (final T element : collection) {
if (predicate.evaluate(element)) {
filtered.add(element);
}
}
return filtered;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment