Annotate often-used Collectors method
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 30 Oct 2015 11:31:18 +0000 (07:31 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 20 Nov 2015 21:13:24 +0000 (16:13 -0500)
commit1f213c174f6568fc7ef84a2c0efaaf5b796c6a3f
treece72b0d3fa2842b25f311b76eed53739c7ab500e
parent04ec39a6cccb054f9b02bf6bcf62ae534d8def89
Annotate often-used Collectors method

We commonly end a Stream with

  .collect(Collectors.toList());

However the returned List is not null-annotated, which means it gives a
warning if we want to save it to a @NonNull List<> reference.

It could be tempting to annotate Stream.collect() directly, however that
would be wrong: there is no guarantee that some shoddy Collector does
not return a null value.

Instead, annotate Collectors.toList(), toSet() and toCollection(), which
should cover for most common use cases.

Change-Id: I8adaf55579bf5b1cc66c5fbb122acc416a4870dc
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/59327
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
common/org.eclipse.tracecompass.common.core/annotations/java/util/stream/Collectors.eea [new file with mode: 0644]
This page took 0.025641 seconds and 5 git commands to generate.