mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 9aaad61ae52463727c77930af532258ea16dd1da
31 lines
697 B
Java
31 lines
697 B
Java
// "Remove folded 'ifPresent()' call" "true"
|
|
|
|
import java.util.Optional;
|
|
|
|
public class After {
|
|
static void setDefaultReviewerForTaskOldStyle(Task task) {
|
|
task.getResponsible().flatMap(Person::getManager).ifPresent(task::setReviewer);
|
|
}
|
|
|
|
class Person {
|
|
private final Department department; // can be null
|
|
|
|
Person(Department department) {
|
|
this.department = department;
|
|
}
|
|
|
|
private Optional<Person> getManager() {
|
|
return Optional.ofNullable(department).map(Department::getManager);
|
|
}
|
|
}
|
|
|
|
interface Department {
|
|
Person getManager(); // never null
|
|
}
|
|
|
|
interface Task {
|
|
Optional<Person> getResponsible();
|
|
|
|
void setReviewer(Person person);
|
|
}
|
|
} |