Java lambdas: Copy nodes from list to a new list
Assuming your Suggestion somewhat possess a public Suggestion copy();
method (like implementing a Copyable<Suggestion>
interface), you could do :
List<Suggestion> only_translations = original_list.stream()
.filter(t -> t.isTranslation)
.map(t -> t.copy()) // or .map(Suggestion::copy)
.collect(Collectors.toList()));
EDIT : with the copy constructor :
List<Suggestion> only_translations = original_list.stream()
.filter(t -> t.isTranslation)
.map(t -> new Suggestion(t)) // or .map(Suggestion::new)
.collect(Collectors.toList()));
Since you say you have a copy constructor, just add this before the collect operation to get a list of copied objects:
.map(Suggestion::new)