Return first non empty list lazyily in Java 8
问题 I have N lists that return data from a Repository. I want to return the first non empty of these three lists (each one executes a different SQL to fetch data). The catch is that I want to do this lazily, so that I don't need to execute a SQL on the database if I have already found an acceptable result. My code is (modified) @Override public List<Something> dataService(Data data) { return firstNonEmptyList(repository.getDataWayOne(data.getParameter()), repository.getDataWayTwo(data