// "Replace Stream API chain with loop" "true" import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; public class Main { public List asList(CharSequence s) { return Collections.singletonList(s); } public List getList() { return Collections.emptyList(); } private void collect() { Map> map = getList() .stream().filter(Objects::nonNull).collect(Collectors.toMap(Function.identity(), this::asList)); System.out.println(map); } }