Код: Выделить всё
Integer yearOfBirth = Optional.ofNullable(employee)
.map(Employee::getDateOfBirth)
.map(LocalDateTime::getYear())
.orElseThrow(new EmployeeException("Date of birth not set for {}", employee));
Подробнее здесь: https://stackoverflow.com/questions/793 ... l-of-chain
Мобильная версия