MatchResult (@NotNull ChooseByNameViewModel base, @NotNull String pattern, @NotNull MinusculeMatcher matcher, @Nullable String name) { if (name == null) { return null; } if (base.getModel() instanceof CustomMatcherModel) { try { //noinspection CastToIncompatibleInterface return ((CustomMatcherModel)base.getModel()).matches(name, pattern) ? new MatchResult(name, 0, true) : null; } catch (Exception e) { LOG.info(e); return null; // no matches appears valid result for "bad" pattern } } return matchName(matcher, name); }