CallMatcher (CallMatcher... matchers) { if (matchers.length == 0) return none(); if (matchers.length == 1) return matchers[0]; return new CallMatcher() { @Override public Stream<String> names() { return Stream.of(matchers).flatMap(CallMatcher::names).distinct(); } @Override public boolean methodReferenceMatches(PsiMethodReferenceExpression methodRef) { for (CallMatcher m : matchers) { if (m.methodReferenceMatches(methodRef)) { return true; } } return false; } @Override public boolean methodMatches(PsiMethod method) { for (CallMatcher m : matchers) { if (m.methodMatches(method)) { return true; } } return false; } @Override public boolean uCallMatches(@Nullable UCallExpression call) { for (CallMatcher m : matchers) { if (m.uCallMatches(call)) { return true; } } return false; } @Override public boolean uCallableReferenceMatches(@Nullable UCallableReferenceExpression reference) { for (CallMatcher m : matchers) { if (m.uCallableReferenceMatches(reference)) { return true; } } return false; } @Override public boolean test(PsiMethodCallExpression call) { for (CallMatcher m : matchers) { if (m.test(call)) { return true; } } return false; } @Override public String toString() { return Stream.of(matchers).map(CallMatcher::toString).collect(Collectors.joining(" or ", "{", "}")); } }; }