common: Annotate Optional.get() as @NonNull
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Mon, 22 Feb 2016 21:41:14 +0000 (16:41 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 23 Feb 2016 20:49:32 +0000 (15:49 -0500)
Optional.get() throws an exception if the value is null, so if the
method returns the value is necessarily @NonNull.

Change-Id: I25cea786763b567b8f7cafcb5a4119f0d359a48b
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/67099
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
common/org.eclipse.tracecompass.common.core/annotations/java/util/Optional.eea [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngWorker.java

diff --git a/common/org.eclipse.tracecompass.common.core/annotations/java/util/Optional.eea b/common/org.eclipse.tracecompass.common.core/annotations/java/util/Optional.eea
new file mode 100644 (file)
index 0000000..74c672c
--- /dev/null
@@ -0,0 +1,4 @@
+class java/util/Optional
+get
+ ()TT;
+ ()T1T;
index e109c4d46ad0f3d307e2738bf49e3ae3265bb669..a5c252c42b9139bca94006bc5bd8cbf597396dd9 100644 (file)
@@ -12,6 +12,7 @@ package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.mode
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
@@ -76,15 +77,15 @@ public class LttngWorker implements IGraphWorker {
             if (tid == -1) {
                 return Collections.EMPTY_MAP;
             }
-            @Nullable KernelAnalysisModule kam = TmfTraceManager.getInstance().getActiveTraceSet().stream()
+            Optional<KernelAnalysisModule> kam = TmfTraceManager.getInstance().getActiveTraceSet().stream()
                         .filter(trace -> trace.getHostId().equals(getHostId()))
                         .map(trace -> TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID))
                         .filter(mod -> mod != null)
-                        .findFirst().get();
-            if (kam == null) {
+                        .findFirst();
+            if (!kam.isPresent()) {
                 return Collections.EMPTY_MAP;
             }
-            ITmfStateSystem ss = kam.getStateSystem();
+            ITmfStateSystem ss = kam.get().getStateSystem();
             if (ss == null) {
                 return Collections.EMPTY_MAP;
             }
This page took 0.027617 seconds and 5 git commands to generate.