import java.util.*; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collector; import static java.util.function.Predicate.isEqual; class InlineRef { Optional findEmpty() { Set children = new HashSet<>(); return children .stream() .filter(where(InlineRef::getName, isEqual(""))) .findAny(); } static Predicate where(Function function, Predicate predicate) { return input -> predicate.test(function.apply(input)); } static String getName(Descriptor desc) { return "name"; } } class Descriptor { }