Don't do that.
If you use a functional pattern, do not bring any imperative/procedural stuff in it.
The purpose of map
is to transform an object into another object. It's meant to be purely functional (side-effect free) by design. Do not violate its functional meaning.
Use forEach
instead:
List<Foo> newFoos = foos.stream()
.filter(foo -> Foo::isBlue)
.collect(toList());
newFoos.forEach(foo -> foo.setTitle("Some value"));
You have nothing to lose here. Even the number of lines remains the same (if you concerned about that). But the code is much more readable and safe.
If you need two pipelines instead of one, then go ahead. Do not try to make the code shorter. The code length in this case has nothing to do with safety and maintainability.