I've got the code below
private static Optional<String> findRangeShortDescriptionWithTitle(final String title,
final Goal goal) {
...
}
...
return scoreCategory.getAllGoals().stream()//
.filter(Goal.class::isInstance)//
.map(Goal.class::cast)//
.map(g -> findRangeShortDescriptionWithTitle(title, g))//
giving the following error
/home/jpschewe/projects/fll-sw/working-dir/src/main/java/fll/documents/writers/SubjectivePdfWriter.java:853: error: [argument] incompatible argument for parameter goal of SubjectivePdfWriter.findRangeShortDescriptionWithTitle.
.map(g -> findRangeShortDescriptionWithTitle(title, g))//
^
found : @Initialized @PolyNull Goal
required: @Initialized @NonNull Goal
I expect that checker wants the goal parameter to finRangeSHortDescriptionWithTitle to have @PolyNull on it. However before that is called in the stream the "isInstance" method is called and that will filter out nulls.