I have an object as follows:
class Order {
private String code;
private String status;
// Constructor, getters and setter and so on
}
I need to create a list of the codes, from a list of orders, which satisfy a condition. I have implemented something similar in JavaScript and it looks like below:
const codes = orders.reduce((codeList, order) => {
if (order.status === 'NEW') return codeList.push(order.code)
return codeList
}, [])
Is it possible to achieve this using Java 8?