boolean (String pattern, @NotNull MatchedValueType type, @NotNull Stream<?> items, Predicate<? super MatchedValue> consumer) { MinusculeMatcher matcher = buildWeightMatcher(pattern); List<MatchedValue> matched = items.map(o -> { if (o instanceof MatchedValue) { return (MatchedValue)o; } Integer weight = ActionSearchUtilKt.calcElementWeight(o, pattern, matcher); return weight == null ? new MatchedValue(o, pattern, type) : new MatchedValue(o, pattern, weight, type); }).collect(Collectors.toList()); try { matched.sort((o1, o2) -> o1.compareWeights(o2)); } catch (IllegalArgumentException e) { LOG.error("Comparison method violates its general contract with pattern '" + pattern + "'", e); } for (MatchedValue t : matched) { if (!consumer.test(t)) { return false; } } return true; }