void () { myCallback.started(myValues.size()); int proceedCount; for (proceedCount = 0; proceedCount < myValues.size() && !myIsCancelled; proceedCount++) { JavaReferenceInfo info = myValues.get(proceedCount); CheckingResult result = myChecker.check(info.getObjectReference()); FilteringTaskCallback.Action action = switch (result.getResult()) { case MATCH -> myCallback.matched(info); case NO_MATCH -> myCallback.notMatched(info); case ERROR -> myCallback.error(info, result.getFailureDescription()); }; if (action == FilteringTaskCallback.Action.STOP) { break; } } FilteringResult reason = myIsCancelled ? FilteringResult.INTERRUPTED : proceedCount == myValues.size() ? FilteringResult.ALL_CHECKED : FilteringResult.LIMIT_REACHED; myCallback.completed(reason); }