/** * Try to find phrase matches sequentially. */ private List<SearchResults.Result> computeSequentially () { return StreamSupport // Use the MatcherSpliterator to create a new stream of // MatchResults. .stream(new MatcherSpliterator(mPhraseMatcher), // Create a sequential stream. false) // Map each MatchResult into a SearchResults.Result. .map(mr -> new SearchResults.Result(mOffset + mr.start())) // Collect all the results into a list. .collect(toList()); }