Код: Выделить всё
Optional.ofNullable(listCanBeNull)
.orElseThrow(() -> new ResourceNotFoundException("the same error message"))
.stream()
.filter(configuration -> configuration.getId().equals(warehouseConfigurationId))
.findAny()
.orElseThrow(() -> new ResourceNotFoundException("the same error message"));
Подробнее здесь: https://stackoverflow.com/questions/734 ... st-is-null