This line and all the following ones can be replaced by the single line

```java
   return cache != null ? new SearchResult(cache) : null;
```