I have Employee class:
public class Employee {
private Long id;
private String name;
private String externalId;
public Employee(Long id, String name, String externalId) {
this.id = id;
this.name = name;
this.externalId = externalId;
}
//getters, setter
}
And employee service which returns an employee (NULL is possible).
private void performEmployeeProcessing() {
Long employeeId = 2L;
Object o = Optional.ofNullable(employeeService.getById(employeeId))
.orElseGet(Employee::new, 1L, "", "");
System.out.println(o);
}
It says compilation error
Employee::new, 1L, "", ""
Cannot resolve constructor.