How can I convert this for loop using the stream.
for (final Foo foo : fooList) {
    if (!FooConstant.FOO_TYPE.equals(foo.getType())) {
        throw new BadRequestException(
          LOGGER,
          FooErrorEnum.NOT_FOO_TYPE.name(),
          String.format("Element %s is not Foo type", foo.getId())
        );
    }
}
I tried doing this way but the foo.getId() is not available in orElseThrow().
Note: BadRequestException is checked exception.
fooList.stream().filter(foo -> !FooConstant.FOO_TYPE.equals(foo.getType())
    .findFirst()
    .orElseThrow(() -> new BadRequestException(LOGGER, FooErrorEnum.NOT_FOO_TYPE.name(), String.format("Element %s is not Foo type", foo.getId()));
 
    