From 1f213c174f6568fc7ef84a2c0efaaf5b796c6a3f Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 30 Oct 2015 07:31:18 -0400 Subject: [PATCH] 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 Reviewed-on: https://git.eclipse.org/r/59327 Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- .../annotations/java/util/stream/Collectors.eea | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/org.eclipse.tracecompass.common.core/annotations/java/util/stream/Collectors.eea diff --git a/common/org.eclipse.tracecompass.common.core/annotations/java/util/stream/Collectors.eea b/common/org.eclipse.tracecompass.common.core/annotations/java/util/stream/Collectors.eea new file mode 100644 index 0000000000..b43230499d --- /dev/null +++ b/common/org.eclipse.tracecompass.common.core/annotations/java/util/stream/Collectors.eea @@ -0,0 +1,10 @@ +class java/util/stream/Collectors +toCollection + ;>(Ljava/util/function/Supplier;)Ljava/util/stream/Collector; + ;>(Ljava/util/function/Supplier;)Ljava/util/stream/Collector; +toList + ()Ljava/util/stream/Collector;>; + ()Ljava/util/stream/Collector;>; +toSet + ()Ljava/util/stream/Collector;>; + ()Ljava/util/stream/Collector;>; -- 2.34.1