Java examples for Lambda Stream:Predicate
Returns first entry from list that passes the match function using Lambda.
//package com.java2s; import java.util.List; import java.util.function.Predicate; public class Main { /** Returns first entry from list that passes the match function. This is * a generalized version of EmployeeUtils.firstMatchingEmployee. */// ww w .j a va2s . c o m public static <T> T firstMatch(List<T> candidates, Predicate<T> matchFunction) { for (T possibleMatch : candidates) { if (matchFunction.test(possibleMatch)) { return (possibleMatch); } } return (null); } }