import com.github.underscore.Underscore;
public class EmployeeFilter {
public static void main(String[] args) {
String[] names = Underscore.chain(employees)
.filter(employee -> employee.getAge() > 30)
.map(Employee::getName)
.toArray(String[]::new);
System.out.println(Arrays.toString(names));
}
}
class Employee {
private String name;
private int age;
public Employee(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
}
<dependencies>
<dependency>
<groupId>com.github.underscore</groupId>
<artifactId>underscore-java</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>