The following code runs through Set
and filters only objects that isActive()
is true
.
public Set<InvoiceLineDocument> getActiveLines() {
Set<InvoiceLineDocument> activeLines = new HashSet<>();
for (InvoiceLineDocument lineDocument : lineDocuments) {
if (lineDocument.isActive())
activeLines.add(lineDocument);
}
return activeLines;
}
How do I convert this implementation to Java 8 stream().filter()
?