From: Patrick Tasse Date: Thu, 28 Jul 2016 20:56:44 +0000 (-0400) Subject: tmf: Change getTracesToBuild trace parameter to be @Nullable X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=f9e76b646c70a81fe3f827f56aa5ef08b6aee39e;p=deliverable%2Ftracecompass.git tmf: Change getTracesToBuild trace parameter to be @Nullable The default implementation already handles a null trace, and VirtualMachineView overrides it as @Nullable. This allows subclasses to call the method with the return value of getTrace(), which can be null, without needing a null check and get an empty list back. Change-Id: Ie7cb5c79bb841796be4e20fcafedb43ad8b2c839 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/78104 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java index 0f1b9dcd90..1324fbdb2f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java @@ -29,6 +29,7 @@ import java.util.TreeSet; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Composite; @@ -571,12 +572,12 @@ public class XmlTimeGraphView extends AbstractTimeGraphView { } @Override - protected @NonNull Iterable getTracesToBuild(@NonNull ITmfTrace trace) { + protected @NonNull Iterable getTracesToBuild(@Nullable ITmfTrace trace) { /* * Return the current trace only. Experiments will return their * children's analyses */ - return Collections.singleton(trace); + return (trace != null) ? Collections.singleton(trace) : Collections.EMPTY_LIST; } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java index fc361c2247..6865e702d4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java @@ -1649,10 +1649,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA * some of which may receive events in live streaming mode. * * @param trace - * The trace associated with this view + * The trace associated with this view, can be null * @return List of traces with data to display */ - protected @NonNull Iterable getTracesToBuild(@NonNull ITmfTrace trace) { + protected @NonNull Iterable getTracesToBuild(@Nullable ITmfTrace trace) { return TmfTraceManager.getTraceSet(trace); }