synchronized (fWorkerStats) {
if (horizontal && graph != null) {
IGraphWorker worker = graph.getParentOf(edge.getVertexFrom());
+ if (worker == null) {
+ return;
+ }
Long duration = edge.getDuration();
Long currentTotal = fWorkerStats.get(worker);
if (currentTotal != null) {
// eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL);
//
// REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq));
- REQUIREMENTS = checkNotNull(Collections.EMPTY_SET);
+ REQUIREMENTS = Collections.EMPTY_SET;
}
@Override
public static Collection<Integer> getThreadIds(KernelAnalysisModule module) {
ITmfStateSystem ss = module.getStateSystem();
if (ss == null) {
- return NonNullUtils.checkNotNull(Collections.EMPTY_SET);
+ return Collections.EMPTY_SET;
}
int threadQuark;
try {
return tids;
} catch (AttributeNotFoundException e) {
}
- return NonNullUtils.checkNotNull(Collections.EMPTY_SET);
+ return Collections.EMPTY_SET;
}
/**
public static List<ITmfStateInterval> getStatusIntervalsForThread(KernelAnalysisModule module, Integer threadId, long start, long end, long resolution, IProgressMonitor monitor) {
ITmfStateSystem ss = module.getStateSystem();
if (ss == null) {
- return NonNullUtils.checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
try {
return statusIntervals;
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
}
- return NonNullUtils.checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
}
protected Iterable<IAnalysisProgressListener> getListeners() {
List<IAnalysisProgressListener> listeners = new ArrayList<>();
for (Object listener : fListeners.getListeners()) {
- listeners.add((IAnalysisProgressListener) listener);
+ if (listener != null) {
+ listeners.add((IAnalysisProgressListener) listener);
+ }
}
return listeners;
}
package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNullContents;
+
import java.util.Arrays;
import java.util.Comparator;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
@Override
public void updateElement(int index) {
final TableViewer tableViewer = fTableViewer;
- final ISegment[] segmentArray = fSegmentArray;
+ final ISegment @Nullable [] segmentArray = fSegmentArray;
if (tableViewer != null && segmentArray != null) {
tableViewer.replace(segmentArray[index], index);
}
public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) {
fTableViewer = (TableViewer) viewer;
if (newInput instanceof ISegmentStore) {
+ @SuppressWarnings("unchecked")
ISegmentStore<ISegment> segmentStore = (ISegmentStore<ISegment>) newInput;
- fSegmentArray = Iterables.toArray(segmentStore, ISegment.class);
+ ISegment[] array = Iterables.toArray(segmentStore, ISegment.class);
+ @NonNull ISegment[] checkedArray = checkNotNullContents(array);
if (fComparator != null) {
- Arrays.sort(fSegmentArray, fComparator);
+ Arrays.sort(checkedArray, fComparator);
}
+ fSegmentArray = checkedArray;
} else if (newInput instanceof ISegment[]) {
- fSegmentArray = ((ISegment[]) newInput).clone();
+ /*
+ * Ensure that there are no null elements in the array, so we can
+ * set it back to fSegmentArray, which does not allow nulls.
+ */
+ @NonNull ISegment[] checkedArray = checkNotNullContents((@Nullable ISegment[]) newInput);
if (fComparator != null) {
- Arrays.sort(fSegmentArray, fComparator);
+ Arrays.sort(checkedArray, fComparator);
}
+ fSegmentArray = checkedArray;
} else {
fSegmentArray = null;
}
@Override
public void setSortOrder(@Nullable Comparator<?> comparator) {
+ @NonNull ISegment @Nullable [] segmentArray = fSegmentArray;
if (comparator == null) {
return;
}
- if (fSegmentArray == null) {
+ if (segmentArray == null) {
return;
}
final TableViewer tableViewer = fTableViewer;
if (tableViewer == null) {
return;
}
- fComparator = (Comparator<ISegment>) comparator;
- Arrays.sort(fSegmentArray, fComparator);
+ @SuppressWarnings("unchecked")
+ Comparator<ISegment> comp = (Comparator<ISegment>) comparator;
+ fComparator = comp;
+ Arrays.sort(segmentArray, fComparator);
tableViewer.refresh();
}
BtfColumnNames.NOTES.toString() };
private static final @NonNull ITmfEventField FIELDS_WITHOUT_NOTES = TmfEventField.makeRoot(FIELD_WITH_NOTES_COLUMNS);
private static final @NonNull ITmfEventField FIELDS_WITH_NOTES = TmfEventField.makeRoot(FIELDS_WITHOUT_NOTES_COLUMNS);
- private final String fName;
+ private final @NonNull String fName;
private final String fDescription;
private final boolean fHasNotes;
private final List<String> fCols;
* @param name the event name
* @param description the event description
*/
- public BtfEventType(String name, String description) {
+ public BtfEventType(@NonNull String name, String description) {
super();
fName = name;
fDescription = description;
package org.eclipse.tracecompass.btf.core.trace;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
+
import java.util.Map;
import org.eclipse.tracecompass.btf.core.Messages;
static {
ImmutableMap.Builder<String, BtfEventType> builder = new ImmutableMap.Builder<>();
// Environment
- builder.put("STI", new BtfEventType(Messages.BtfTypeId_STIName, Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$
+ builder.put("STI", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_STIName), Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$
// Software
- builder.put("T", new BtfEventType(Messages.BtfTypeId_TName, Messages.BtfTypeId_TDescr)); //$NON-NLS-1$
- builder.put("ISR", new BtfEventType(Messages.BtfTypeId_ISRName, Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$
- builder.put("R", new BtfEventType(Messages.BtfTypeId_RName, Messages.BtfTypeId_RDescr)); //$NON-NLS-1$
- builder.put("IB", new BtfEventType(Messages.BtfTypeId_IBName, Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$
+ builder.put("T", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_TName), Messages.BtfTypeId_TDescr)); //$NON-NLS-1$
+ builder.put("ISR", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ISRName), Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$
+ builder.put("R", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_RName), Messages.BtfTypeId_RDescr)); //$NON-NLS-1$
+ builder.put("IB", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_IBName), Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$
// Hardware
- builder.put("ECU", new BtfEventType(Messages.BtfTypeId_ECUName, Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$
- builder.put("P", new BtfEventType(Messages.BtfTypeId_PName, Messages.BtfTypeId_PDescr)); //$NON-NLS-1$
- builder.put("C", new BtfEventType(Messages.BtfTypeId_CName, Messages.BtfTypeId_CDescr)); //$NON-NLS-1$
+ builder.put("ECU", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ECUName), Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$
+ builder.put("P", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_PName), Messages.BtfTypeId_PDescr)); //$NON-NLS-1$
+ builder.put("C", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_CName), Messages.BtfTypeId_CDescr)); //$NON-NLS-1$
// Operating system
- builder.put("SCHED", new BtfEventType(Messages.BtfTypeId_SCHEDName, Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$
- builder.put("SIG", new BtfEventType(Messages.BtfTypeId_SIGName, Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$
- builder.put("SEM", new BtfEventType(Messages.BtfTypeId_SEMName, Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$
+ builder.put("SCHED", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SCHEDName), Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$
+ builder.put("SIG", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIGName), Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$
+ builder.put("SEM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SEMName), Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$
// Information
- builder.put("SIM", new BtfEventType(Messages.BtfTypeId_SIMName, Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$
+ builder.put("SIM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIMName), Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$
TYPES = builder.build();
}
package org.eclipse.tracecompass.common.core.collect;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.function.Function;
import java.util.stream.Stream;
* recursively.
*/
public Stream<T> flatten(T element) {
- return Stream.concat(
+ Stream<T> ret = Stream.concat(
Stream.of(element),
fGetChildrenFunction.apply(element).flatMap(this::flatten));
+ return checkNotNull(ret);
}
}
*
* @return The set of custom attributes
*/
- Set<String> getCustomAttributes();
+ @NonNull Set<@NonNull String> getCustomAttributes();
/**
* Get the value of a given CTF attribute.
}
sb.append("type:").append(fContainerType.toString()); //$NON-NLS-1$
sb.append(']');
- String string = sb.toString();
- return string;
+ return sb.toString();
}
@Override
// Attributes
// ------------------------------------------------------------------------
- private final ImmutableList<String> fFieldNames;
+ private final @NonNull List<String> fFieldNames;
private final Definition[] fDefinitions;
private Map<String, Definition> fDefinitionsMap = null;
}
@Override
- public List<String> getFieldNames() {
+ public @NonNull List<String> getFieldNames() {
return fFieldNames;
}
builder.append("{ "); //$NON-NLS-1$
- if (fFieldNames != null) {
- List<String> fields = new LinkedList<>();
- for (String field : fFieldNames) {
- String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$
- fields.add(appendee);
- }
- Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
- builder.append(joiner.join(fields));
+ List<String> fields = new LinkedList<>();
+ for (String field : fFieldNames) {
+ String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$
+ fields.add(appendee);
}
+ Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
+ builder.append(joiner.join(fields));
builder.append(" }"); //$NON-NLS-1$
import java.util.Collection;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
fPaths.put(fieldName, fieldName + '[' + collection.size() + ']');
}
List<String> paths = (List<String>) fPaths.get(fieldName);
- Builder<Definition> definitions = new ImmutableList.Builder<>();
+ Builder<@NonNull Definition> definitions = new ImmutableList.Builder<>();
for (int i = 0; i < length; i++) {
/* We should not have inserted any null values */
String elemName = checkNotNull(paths.get(i));
definitions.add(fElemType.createDefinition(definitionScope, elemName, input));
}
- List<Definition> list = checkNotNull(definitions.build());
+ List<@NonNull Definition> list = checkNotNull(definitions.build());
return new ArrayDefinition(this, definitionScope, fieldName, list);
}
*/
public final class EventHeaderDefinition extends Definition implements ICompositeDefinition {
- private static final List<String> FIELD_NAMES = ImmutableList.of(
+ private static final @NonNull List<String> FIELD_NAMES = ImmutableList.of(
IEventHeaderDeclaration.ID,
IEventHeaderDeclaration.TIMESTAMP
);
}
@Override
- public List<String> getFieldNames() {
+ public @NonNull List<String> getFieldNames() {
return FIELD_NAMES;
}
}
\ No newline at end of file
*/
@Test
public void testEventLookup() {
- Set<? extends ITmfEventType> eventTypes = fixture.getContainedEventTypes();
+ Set<@NonNull ? extends ITmfEventType> eventTypes = fixture.getContainedEventTypes();
Set<String> eventNames = TmfEventTypeCollectionHelper.getEventNames(eventTypes);
assertTrue(eventNames.contains("sched_switch"));
assertFalse(eventNames.contains("Sched_switch"));
import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import static org.eclipse.tracecompass.common.core.NonNullUtils.equalsNullable;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
/** An invalid location */
public static final CtfLocation NULL_LOCATION = new CtfLocation(CtfLocation.INVALID_LOCATION);
- private final CtfTmfTrace fTrace;
+ private final @NonNull CtfTmfTrace fTrace;
private CtfLocation fCurLocation;
private long fCurRank;
* If the iterator couldn't not be instantiated, probably due to
* a read error.
*/
- public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace) throws CTFException {
+ public CtfIterator(CTFTrace ctfTrace, @NonNull CtfTmfTrace ctfTmfTrace) throws CTFException {
super(ctfTrace);
fTrace = ctfTmfTrace;
if (hasMoreEvents()) {
* If the iterator couldn't not be instantiated, probably due to
* a read error.
*/
- public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank)
+ public CtfIterator(CTFTrace ctfTrace, @NonNull CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank)
throws CTFException {
super(ctfTrace);
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = (prime * result)
- + ((fTrace == null) ? 0 : fTrace.hashCode());
+ result = (prime * result) + fTrace.hashCode();
result = (prime * result)
+ ((fCurLocation == null) ? 0 : fCurLocation.hashCode());
result = (prime * result) + (int) (fCurRank ^ (fCurRank >>> 32));
if (declaration == null) {
return new HashSet<>();
}
- return checkNotNull(declaration.getCustomAttributes());
+ return declaration.getCustomAttributes();
}
@Override
* String The name to assign to this field
* @return The resulting CtfTmfEventField object
*/
- public static CtfTmfEventField parseField(IDefinition fieldDef,
+ public static @NonNull CtfTmfEventField parseField(IDefinition fieldDef,
@NonNull String fieldName) {
CtfTmfEventField field = null;
package org.eclipse.tracecompass.tmf.ctf.core.event;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
* @param content
* The event field
*/
- public CtfTmfEventType(String eventName, ITmfEventField content) {
+ public CtfTmfEventType(@NonNull String eventName, ITmfEventField content) {
super(eventName, content);
}
null,
content.toArray(new ITmfEventField[content.size()]));
- ctfTmfEventType = new CtfTmfEventType(ied.getName(), contentTree);
+ ctfTmfEventType = new CtfTmfEventType(checkNotNull(ied.getName()), contentTree);
fContainedEventTypes.put(ctfTmfEventType.getName(), ctfTmfEventType);
}
}
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells.TestCommandShell;
import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandOutputListener;
// Save output/result in command map
if (output != null && errorOutput != null) {
commandMap.put(input, createCommandResult(result,
- checkNotNull(output.toArray(new String[output.size()])),
- checkNotNull(errorOutput.toArray(new String[errorOutput.size()]))));
+ checkNotNull(output.toArray(new @NonNull String[output.size()])),
+ checkNotNull(errorOutput.toArray(new @NonNull String[errorOutput.size()]))));
}
inOutput = false;
} else if (OUTPUT_KEY.equals(strLine)) {
return checkNotNull(commands.get(fullCommand));
}
- String[] output = new String[1];
+ @NonNull String[] output = new @NonNull String[1];
output[0] = String.valueOf("Command not found");
ICommandResult result = createCommandResult(1, output, output);
return result;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
@Override
public boolean isEnabled() {
- ArrayList<BaseEventComponent> events = new ArrayList<>();
+ @NonNull ArrayList<@NonNull BaseEventComponent> events = new ArrayList<>();
TraceSessionComponent[] sessions = null;
Boolean isKernel = null;
@Override
public List<String> getSessionNames(IProgressMonitor monitor) throws ExecutionException {
- return checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
@Override
@Override
public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException {
- return checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
@Override
public List<IUstProviderInfo> getUstProvider() throws ExecutionException {
- return checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
@Override
public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException {
- return checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
@Override
@Override
public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException {
- return checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
@Override
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.File;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.logging.ControlCommandLogger;
/**
* @return value of tracing group preference
*/
- public String getTracingGroup() {
- return fPreferenceStore.getString(TRACE_CONTROL_TRACING_GROUP_PREF);
+ public @NonNull String getTracingGroup() {
+ return checkNotNull(fPreferenceStore.getString(TRACE_CONTROL_TRACING_GROUP_PREF));
}
/**
}
String[] args = commandLine.split("\\s+"); //$NON-NLS-1$
ICommandInput command = fCommandShell.createCommand();
- command.addAll(checkNotNull(Arrays.asList(args)));
+ command.addAll(Arrays.asList(args));
ICommandResult result = executeCommand(command, monitor);
if (isError(result)) {
protected @NonNull ICommandInput createCommand(String... segments) {
ICommandInput command = fCommandShell.createCommand();
command.add(LTTngControlServiceConstants.CONTROL_COMMAND);
- List<String> groupOption = getTracingGroupOption();
+ List<@NonNull String> groupOption = getTracingGroupOption();
if (!groupOption.isEmpty()) {
command.addAll(groupOption);
}
/**
* @return the tracing group option if configured in the preferences
*/
- protected @NonNull List<String> getTracingGroupOption() {
- List<String> groupOption = new ArrayList<>();
+ protected @NonNull List<@NonNull String> getTracingGroupOption() {
+ List<@NonNull String> groupOption = new ArrayList<>();
if (!ControlPreferences.getInstance().isDefaultTracingGroup() && !ControlPreferences.getInstance().getTracingGroup().equals("")) { //$NON-NLS-1$
groupOption.add(LTTngControlServiceConstants.OPTION_TRACING_GROUP);
groupOption.add(ControlPreferences.getInstance().getTracingGroup());
protected ICommandInput createCommand(String... strings) {
ICommandInput command = getCommandShell().createCommand();
command.add(LTTngControlServiceConstants.CONTROL_COMMAND);
- List<String> groupOption = getTracingGroupOption();
+ List<@NonNull String> groupOption = getTracingGroupOption();
if (!groupOption.isEmpty()) {
command.addAll(groupOption);
}
import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
- Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2);
+ Set<@NonNull ITmfTrace> traces = ImmutableSet.of(trace1, trace2);
runCpuTest(traces, "Match TCP events", 100);
trace1.dispose();
CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_DB);
CtfTmfTrace trace3 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_HTTPD);
- Set<ITmfTrace> traces = ImmutableSet.of((ITmfTrace) trace1, trace2, trace3);
+ Set<@NonNull ITmfTrace> traces = ImmutableSet.of(trace1, trace2, trace3);
runCpuTest(traces, "Django traces", 10);
runMemoryTest(traces, "Django traces", 10);
trace3.dispose();
}
- private static void runCpuTest(Set<ITmfTrace> testTraces, String testName, int loop_count) {
+ private static void runCpuTest(Set<@NonNull ITmfTrace> testTraces, String testName, int loop_count) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME);
perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME);
}
/* Benchmark memory used by the algorithm */
- private static void runMemoryTest(Set<ITmfTrace> testTraces, String testName, int loop_count) {
+ private static void runMemoryTest(Set<@NonNull ITmfTrace> testTraces, String testName, int loop_count) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY);
perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP);
import java.util.Collections;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
trace3.dispose();
}
- private static void runCpuTest(TmfExperiment experiment, String testName, int loop_count) {
+ private static void runCpuTest(@NonNull TmfExperiment experiment, String testName, int loop_count) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME);
perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME);
for (int i = 0; i < loop_count; i++) {
pm.start();
- SynchronizationManager.synchronizeTraces(null, Collections.<ITmfTrace> singleton(experiment), true);
+ SynchronizationManager.synchronizeTraces(null, Collections.singleton(experiment), true);
pm.stop();
}
pm.commit();
}
/* Benchmark memory used by the algorithm */
- private static void runMemoryTest(TmfExperiment experiment, String testName, int loop_count) {
+ private static void runMemoryTest(@NonNull TmfExperiment experiment, String testName, int loop_count) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY);
perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP);
System.gc();
pm.start();
- SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Collections.<ITmfTrace> singleton(experiment), true);
+ SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Collections.singleton(experiment), true);
assertNotNull(algo);
System.gc();
package org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.File;
import java.util.HashSet;
import java.util.Set;
* experiment
*/
public synchronized TmfExperiment getExperiment(boolean deleteSuppFiles) {
- Set<ITmfTrace> traces = new HashSet<>();
+ Set<@NonNull ITmfTrace> traces = new HashSet<>();
for (VmTraces trace : fTraces) {
- traces.add(trace.getTrace());
+ ITmfTrace tmfTrace = trace.getTrace();
+ if (tmfTrace != null) {
+ traces.add(tmfTrace);
+ }
}
- @SuppressWarnings("null")
- @NonNull String expName = this.name();
+ String expName = checkNotNull(this.name());
VirtualMachineExperiment experiment = new VirtualMachineExperiment(expName, traces);
if (deleteSuppFiles) {
/*
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.lttng2.kernel.core.tests.Activator;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
*
* @return A TmfXmlTraceStub reference to this trace
*/
- public ITmfTrace getTrace() {
+ public @Nullable ITmfTrace getTrace() {
ITmfTrace trace = new TmfXmlTraceStub();
IStatus status = trace.validate(null, fPath.toOSString());
if (!status.isOK()) {
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching;
import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
- List<ITmfTrace> tracearr = new LinkedList<>();
+ List<@NonNull ITmfTrace> tracearr = new LinkedList<>();
tracearr.add(trace1);
tracearr.add(trace2);
package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
+
import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider;
}
Integer tid = EventField.getInt(event, eventLayout.fieldTid());
- String name = EventField.getOrDefault(event, eventLayout.fieldName(), Messages.TraceEventHandlerSched_UnknownThreadName);
+ String name = EventField.getOrDefault(event, eventLayout.fieldName(), nullToEmptyString(Messages.TraceEventHandlerSched_UnknownThreadName));
Integer status = EventField.getInt(event, eventLayout.fieldStatus());
String host = event.getTrace().getHostId();
package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.trace;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
import java.util.Collections;
import java.util.Set;
* Default constructor. Needed by the extension point.
*/
public VirtualMachineExperiment() {
- this("", checkNotNull(Collections.EMPTY_SET)); //$NON-NLS-1$
+ this("", Collections.EMPTY_SET); //$NON-NLS-1$
}
/**
* Add this library to the pending entries, the matching
* build_id/debug_link event will finish updating this attribute
*/
- fPendingEntries.put(baddr, sopath);
+ fPendingEntries.put(baddr, checkNotNull(sopath));
}
/**
package org.eclipse.tracecompass.lttng2.ust.core.analysis.memory;
import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
import java.util.Set;
* In order to have these events, the libc wrapper with probes should be
* loaded
*/
- eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation);
- eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation);
+ eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingInformation));
+ eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation));
/* The domain type of the analysis */
TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
import java.util.Arrays;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
public Map<String, String> getFields() {
Map<String, String> map = fFields;
if (map == null) {
- Builder<String, String> builder = ImmutableMap.<String, String> builder()
+ Builder<String, String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder()
.put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$
.put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$
.put("Sequence Number", String.valueOf(fSequenceNumber)) //$NON-NLS-1$
import java.nio.ByteOrder;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
public Map<String, String> getFields() {
Map<String, String> map = fFields;
if (map == null) {
- ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder()
+ ImmutableMap.Builder<String, String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder()
.put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$
.put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$
.put("Length", String.valueOf(fTotalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
import java.nio.ByteBuffer;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
if (map == null) {
byte[] array = checkNotNull(fPayload.array());
- Builder<String, String> builder = ImmutableMap.<String, String> builder()
+ Builder<String, String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder()
.put("Binary", ConversionHelper.bytesToHex(array, true)); //$NON-NLS-1$
try {
String s = new String(array, "UTF-8"); //$NON-NLS-1$
}
// Convenience method
- private static ITmfEventField[] generatePacketFields(Packet packet) {
+ private static ITmfEventField @NonNull [] generatePacketFields(Packet packet) {
List<ITmfEventField> fieldList = new ArrayList<>();
List<ITmfEventField> subfieldList = new ArrayList<>();
Packet localPacket = packet;
while (localPacket != null) {
subfieldList.clear();
- for (Map.Entry<String, String> entry : localPacket.getFields().entrySet()) {
-
- @SuppressWarnings("null")
- @NonNull
+ for (Map.Entry<@NonNull String, @NonNull String> entry : localPacket.getFields().entrySet()) {
String key = entry.getKey();
-
- @SuppressWarnings("null")
- @NonNull
String value = entry.getValue();
subfieldList.add(new TmfEventField(key, value, null));
}
}
if (packet == null) {
- fProtocols = checkNotNull(Collections.EMPTY_LIST);
+ fProtocols = Collections.EMPTY_LIST;
return fProtocols;
}
// Go through all the packets and add them to list.
package org.eclipse.tracecompass.internal.tmf.pcap.core.event;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
* @throws IllegalArgumentException
* If 'name' is null, or if 'fields' has duplicate field names.
*/
- public PcapEventField(String name, Object value, @Nullable ITmfEventField[] fields, Packet packet) {
+ public PcapEventField(String name, Object value, ITmfEventField[] fields, Packet packet) {
super(name, value, fields);
fSummaryString = packet.getLocalSummaryString();
}
* @throws IllegalArgumentException
* If 'name' is null, or if 'fields' has duplicate field names.
*/
- public PcapRootEventField(@Nullable ITmfEventField[] fields, Packet packet) {
+ public PcapRootEventField(ITmfEventField[] fields, Packet packet) {
super(ITmfEventField.ROOT_FIELD_ID, null, fields);
fPacketSourceField = new TmfEventField(PcapEvent.EVENT_FIELD_PACKET_SOURCE,
packet.getMostEcapsulatedPacket().getSourceEndpoint().toString(), null);
private static final long serialVersionUID = -3257452887960883177L;
- private static final Comparator<ISegment> COMPARATOR = checkNotNull(Ordering
- .from(SegmentComparators.INTERVAL_START_COMPARATOR)
- .compound(SegmentComparators.INTERVAL_END_COMPARATOR));
+ private static final Comparator<ISegment> COMPARATOR;
+ static {
+ /* checkNotNull() has to be called separately, or else it breaks the
+ * type inference. */
+ Comparator<ISegment> comp = Ordering
+ .from(SegmentComparators.INTERVAL_START_COMPARATOR)
+ .compound(SegmentComparators.INTERVAL_END_COMPARATOR);
+ COMPARATOR = checkNotNull(comp);
+ }
private final long fStart;
private final long fEnd;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFactory;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
*/
@Test
public void testDoQuery() {
- List<ITmfStateInterval> interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
+ List<@Nullable ITmfStateInterval> interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
interval.add(null);
}
testInterval(interval[8], 908, 998, 9);
testInterval(interval[9], 909, 999, 9);
- List<ITmfStateInterval> intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
+ List<@Nullable ITmfStateInterval> intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES);
for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
intervalQuery.add(null);
}
import static org.junit.Assert.assertTrue;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
*
* @author Naser Ezzati
*/
+@NonNullByDefault
public class StateValueCompareToTest {
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
/**
* State history back-end that stores its intervals in RAM only. It cannot be
}
private static Iterator<ITmfStateInterval> serachforEndTime(TreeSet<ITmfStateInterval> tree, long time) {
- ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, null);
+ ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, TmfStateValue.nullValue());
ITmfStateInterval myInterval = tree.lower(dummyInterval);
if (myInterval == null) {
return tree.iterator();
import java.io.IOException;
import java.nio.ByteBuffer;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
private final long start;
private final long end;
private final int attribute;
- private final TmfStateValue sv;
+ private final @NonNull TmfStateValue sv;
/*
* Size of the strings section entry used by this interval (= 0 if not used)
* If the start time or end time are invalid
*/
public HTInterval(long intervalStart, long intervalEnd, int attribute,
- TmfStateValue value) throws TimeRangeException {
+ @NonNull TmfStateValue value) throws TimeRangeException {
if (intervalStart > intervalEnd) {
throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$
}
* {@link #computeStringsEntrySize()} and do an extra copy.
*/
private HTInterval(long intervalStart, long intervalEnd, int attribute,
- TmfStateValue value, int size) throws TimeRangeException {
+ @NonNull TmfStateValue value, int size) throws TimeRangeException {
if (intervalStart > intervalEnd) {
throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$
}
import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
* @throws IOException
* If there was an error reading from the file channel
*/
- public static final HTNode readNode(HTConfig config, FileChannel fc)
+ public static final @NonNull HTNode readNode(HTConfig config, FileChannel fc)
throws IOException {
HTNode newNode = null;
int res, i;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.statesystem.core.Activator;
/**
* reading. Instead of using a big reader-writer lock, we'll
* just catch this exception.
*/
- public synchronized HTNode readNode(int seqNumber) throws ClosedChannelException {
+ public synchronized @NonNull HTNode readNode(int seqNumber) throws ClosedChannelException {
/* Do a cache lookup */
int offset = seqNumber & (CACHE_SIZE - 1);
HTNode readNode = fNodeCache[offset];
/* Put the node in the cache. */
fNodeCache[offset] = readNode;
return readNode;
+
} catch (ClosedChannelException e) {
throw e;
} catch (IOException e) {
/* Other types of IOExceptions shouldn't happen at this point though */
Activator.getDefault().logError(e.getMessage(), e);
- return null;
+ throw new IllegalStateException();
}
}
import java.util.Collections;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.statesystem.core.Activator;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
private int fNodeCount;
/** "Cache" to keep the active nodes in memory */
- private final List<HTNode> fLatestBranch;
+ private final List<@NonNull HTNode> fLatestBranch;
// ------------------------------------------------------------------------
// Constructors/"Destructors"
fConfig = conf;
fTreeEnd = conf.getTreeStart();
fNodeCount = 0;
- fLatestBranch = Collections.synchronizedList(new ArrayList<HTNode>());
+ fLatestBranch = Collections.synchronizedList(new ArrayList<>());
/* Prepare the IO object */
fTreeIO = new HT_IO(fConfig, true);
* start
* @throws ClosedChannelException
*/
- private List<HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
- List<HTNode> list = new ArrayList<>();
+ private List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
+ List<@NonNull HTNode> list = new ArrayList<>();
HTNode nextChildNode = fTreeIO.readNode(rootNodeSeqNb);
list.add(nextChildNode);
*
* @return The immutable latest branch
*/
- protected List<HTNode> getLatestBranch() {
+ protected List<@NonNull HTNode> getLatestBranch() {
return ImmutableList.copyOf(fLatestBranch);
}
* Start time of the new node
* @return The newly created node
*/
- private CoreNode initNewCoreNode(int parentSeqNumber, long startTime) {
+ private @NonNull CoreNode initNewCoreNode(int parentSeqNumber, long startTime) {
CoreNode newNode = new CoreNode(fConfig, fNodeCount, parentSeqNumber,
startTime);
fNodeCount++;
* Start time of the new node
* @return The newly created node
*/
- private LeafNode initNewLeafNode(int parentSeqNumber, long startTime) {
+ private @NonNull LeafNode initNewLeafNode(int parentSeqNumber, long startTime) {
LeafNode newNode = new LeafNode(fConfig, fNodeCount, parentSeqNumber,
startTime);
fNodeCount++;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
*/
// FIXME change to IStateInterval?
void insertPastState(long stateStartTime, long stateEndTime,
- int quark, ITmfStateValue value) throws TimeRangeException;
+ int quark, @NonNull ITmfStateValue value) throws TimeRangeException;
/**
* Indicate to the provider that we are done building the history (so it can
* @throws StateSystemDisposedException
* If the state system is disposed while a request is ongoing.
*/
- void doQuery(@NonNull List<ITmfStateInterval> currentStateInfo, long t)
+ void doQuery(@NonNull List<@Nullable ITmfStateInterval> currentStateInfo, long t)
throws TimeRangeException, StateSystemDisposedException;
/**
package org.eclipse.tracecompass.statesystem.core.interval;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
import com.google.common.base.Objects;
private final long start;
private final long end;
private final int attribute;
- private final ITmfStateValue sv;
+ private final @NonNull ITmfStateValue sv;
/**
* Construct an interval from its given parameters
* State value this interval will contain
*/
public TmfStateInterval(long start, long end, int attribute,
- ITmfStateValue sv) {
+ @NonNull ITmfStateValue sv) {
this.start = start;
this.end = end;
this.attribute = attribute;
package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
import java.util.Collections;
import java.util.List;
*/
public TmfXmlReadOnlyStateValue(TmfXmlReadOnlyModelFactory modelFactory, Element node,
IXmlStateSystemContainer container, String eventField) {
- super(modelFactory, node, container, checkNotNull(Collections.EMPTY_LIST), eventField);
+ super(modelFactory, node, container, Collections.EMPTY_LIST, eventField);
}
}
public class XmlStateProvider extends AbstractTmfStateProvider implements IXmlStateSystemContainer {
private final IPath fFilePath;
- @NonNull private final String fStateId;
+ private final @NonNull String fStateId;
/** List of all Event Handlers */
private final List<TmfXmlEventHandler> fEventHandlers = new ArrayList<>();
/** List of all Locations */
- private final Set<TmfXmlLocation> fLocations;
+ private final @NonNull Set<@NonNull TmfXmlLocation> fLocations;
/** Map for defined values */
private final Map<String, String> fDefinedValues = new HashMap<>();
/* parser for the locations */
List<Element> childElements = XmlUtils.getChildElements(doc, TmfXmlStrings.LOCATION);
- Set<TmfXmlLocation> locations = new HashSet<>();
+ Set<@NonNull TmfXmlLocation> locations = new HashSet<>();
for (Element element : childElements) {
if (element == null) {
continue;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
import org.eclipse.tracecompass.tmf.analysis.xml.core.module.Messages;
import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils;
.append("org.eclipse.linuxtools.tmf.analysis.xml.core") //$NON-NLS-1$
.append("xml_files"); //$NON-NLS-1$
- private static List<IAnalysisModuleHelper> fModules = null;
+ private static List<@NonNull IAnalysisModuleHelper> fModules = null;
/**
* Constructor. It adds the new module listener to the analysis manager.
@Override
public synchronized Iterable<IAnalysisModuleHelper> getAnalysisModules() {
- if (fModules == null) {
- fModules = new ArrayList<>();
+ List<@NonNull IAnalysisModuleHelper> modules = fModules;
+ if (modules == null) {
+ modules = new ArrayList<>();
+ fModules = modules;
populateBuiltinModules();
populateAnalysisModules();
}
- return fModules;
+ return modules;
}
private static void processFile(File xmlFile) {
return;
}
- Set<ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
+ Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
if (analysisIds.isEmpty()) {
/*
* No analysis specified, take all state system analysis modules
import java.util.List;
import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
private static final String VALUE_F = "Test Value F";
/* Requirement information strings */
- private static final String INFO_A = "This is an information.";
- private static final String INFO_B = "This is another information.";
- private static final String INFO_C = "This is the last information.";
+ private static final @NonNull String INFO_A = "This is an information.";
+ private static final @NonNull String INFO_B = "This is another information.";
+ private static final @NonNull String INFO_C = "This is the last information.";
/**
* Test suite for the {@link TmfAnalysisRequirement#addInformation} and the
private final @NonNull ITmfTrace fTrace = STUB_TRACE.getTrace();
- private final String fTypeId = "TestType";
+ private final @NonNull String fTypeId = "TestType";
private final @NonNull String fLabel1 = "AString";
private final @NonNull String fLabel2 = "AnInteger";
private final String[] fLabels = new String[] { fLabel1, fLabel2 };
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
*/
public class TmfAsyncSequenceDiagramEventTest {
- private final String fTypeId = "Some type";
+ private final @NonNull String fTypeId = "Some type";
private final String fLabel0 = "label1";
private final String fLabel1 = "label2";
private final String[] fLabels = new String[] { fLabel0, fLabel1 };
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
*/
public class TmfSyncSequenceDiagramEventTest {
- private final String fTypeId = "Some type";
- private final String fLabel0 = "label1";
- private final String fLabel1 = "label2";
+ private final @NonNull String fTypeId = "Some type";
+ private final @NonNull String fLabel0 = "label1";
+ private final @NonNull String fLabel1 = "label2";
private final String[] fLabels = new String[] { fLabel0, fLabel1 };
private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
package org.eclipse.tracecompass.tmf.tests.stubs.trace.text;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
/**
public class SyslogEventType extends TmfEventType {
/** The event type id string. */
- public static final String TYPE_ID = "Syslog"; //$NON-NLS-1$
+ public static final @NonNull String TYPE_ID = "Syslog"; //$NON-NLS-1$
/** A default instance of this class */
public static final SyslogEventType INSTANCE = new SyslogEventType();
if (elementName.equals(SOURCE_ELEM)) {
try {
IAnalysisModuleSource source = (IAnalysisModuleSource) ce.createExecutableExtension(CLASS_ATTR);
- sources.add(source);
+ if (source != null) {
+ sources.add(source);
+ }
} catch (InvalidRegistryObjectException e) {
Activator.logError("Error creating module source", e); //$NON-NLS-1$
} catch (CoreException e) {
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.collapse.ITmfCollapsibleEvent;
import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode;
}
@Override
- public ITmfFilterTreeNode[] getChildren() {
- return new ITmfFilterTreeNode[0];
+ public @NonNull ITmfFilterTreeNode[] getChildren() {
+ return new @NonNull ITmfFilterTreeNode[0];
}
@Override
package org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNullContents;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.CountDownLatch;
+import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
}
@Override
- public void doQuery(List<ITmfStateInterval> currentStateInfo, long t)
+ public void doQuery(List<@Nullable ITmfStateInterval> currentStateInfo, long t)
throws TimeRangeException, StateSystemDisposedException {
/* Wait for required steps to be done */
waitForCheckpoints();
* Set the initial contents of the partial state system (which is the
* contents of the query at the checkpoint).
*/
+ List<@NonNull ITmfStateInterval> filledStateInfo =
+ checkNotNullContents(currentStateInfo.stream()).collect(Collectors.toList());
+
fPartialSS.takeQueryLock();
- fPartialSS.replaceOngoingState(currentStateInfo);
+ fPartialSS.replaceOngoingState(filledStateInfo);
/* Send an event request to update the state system to the target time. */
TmfTimeRange range = new TmfTimeRange(
try {
for (int i = 0; i < currentStateInfo.size(); i++) {
long start = 0;
- ITmfStateValue val = null;
start = ((ITmfStateSystem) fPartialSS).getOngoingStartTime(i);
- val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i);
+ ITmfStateValue val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i);
- ITmfStateInterval interval = new TmfStateInterval(start, t, i, val);
+ ITmfStateInterval interval = new TmfStateInterval(start, t, i, checkNotNull(val));
currentStateInfo.set(i, interval);
}
} catch (AttributeNotFoundException e) {
*******************************************************************************/
package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
/**
* @param ts
* The timestamp of the event
*/
- public void updateMipmap(ITmfStateValue value, long ts);
+ public void updateMipmap(@NonNull ITmfStateValue value, long ts);
/**
* Update the mipmap values at all levels before closing.
*******************************************************************************/
package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.List;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
} catch (StateValueTypeException e) {
e.printStackTrace();
}
- return maxValue;
+ return checkNotNull(maxValue);
}
}
*******************************************************************************/
package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.List;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
} catch (StateValueTypeException e) {
e.printStackTrace();
}
- return minValue;
+ return checkNotNull(minValue);
}
}
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
public abstract class TmfMipmapFeature implements ITmfMipmapFeature {
/** The current state value */
- protected ITmfStateValue currentValue = TmfStateValue.nullValue();
+ protected @NonNull ITmfStateValue currentValue = TmfStateValue.nullValue();
/** The current start time for the state value */
protected long currentStartTime;
/** The list of ongoing state intervals per mipmap level */
* The end time of the mipmap interval
* @return A state value to be stored in the mipmap level attribute
*/
- protected abstract ITmfStateValue computeMipmapValue(List<ITmfStateInterval> lowerIntervals, long startTime, long endTime);
+ protected abstract @NonNull ITmfStateValue computeMipmapValue(List<ITmfStateInterval> lowerIntervals, long startTime, long endTime);
/**
* Get the mipmap resolution
* @return An iterable list of analysis this analyzes depends on.
*/
protected Iterable<IAnalysisModule> getDependentAnalyses() {
- return checkNotNull(Collections.EMPTY_LIST);
+ return Collections.EMPTY_LIST;
}
private void execute(final ITmfTrace trace) {
@Override
public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
- return checkNotNull(Collections.EMPTY_SET);
+ return Collections.EMPTY_SET;
}
}
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
/**
*
* @return List of {@link ITmfNewAnalysisModuleListener}
*/
- public static Iterable<ITmfNewAnalysisModuleListener> getOutputListeners() {
- List<ITmfNewAnalysisModuleListener> newModuleListeners = new ArrayList<>();
+ public static Iterable<@NonNull ITmfNewAnalysisModuleListener> getOutputListeners() {
+ List<@NonNull ITmfNewAnalysisModuleListener> newModuleListeners = new ArrayList<>();
// Get the sources element from the extension point
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
for (IConfigurationElement ce : config) {
private final String fType;
private final Map<String, ValuePriorityLevel> fValues = new HashMap<>();
- private final Set<String> fInformation = new HashSet<>();
+ private final Set<@NonNull String> fInformation = new HashSet<>();
/**
* The possible level for each value. They must be listed in ascending order
* @param information
* The information to be added
*/
- public void addInformation(String information) {
+ public void addInformation(@NonNull String information) {
fInformation.add(information);
}
*
* @return The set of all the information
*/
- public Set<String> getInformation() {
+ public Set<@NonNull String> getInformation() {
return fInformation;
}
* an empty list if no children (return value cannot be null).
*/
@NonNull
- <T extends ITmfEventProvider> List<T> getChildren(Class<T> clazz);
+ <T extends ITmfEventProvider> List<@NonNull T> getChildren(Class<T> clazz);
/**
* Gets the number of children
package org.eclipse.tracecompass.tmf.core.component;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@Override
public <T extends ITmfEventProvider> List<T> getChildren(Class<T> clazz) {
- List<T> list = new ArrayList<>();
+ List<@NonNull T> list = new ArrayList<>();
synchronized (fChildren) {
for (TmfEventProvider child : fChildren) {
if (clazz.isAssignableFrom(child.getClass())) {
- list.add(clazz.cast(child));
+ list.add(checkNotNull(clazz.cast(child)));
}
}
}
* @return the name of the event, same as getType().getName()
* @since 1.0
*/
- String getName();
+ @NonNull String getName();
}
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
*
* @return The array (possibly empty) of children nodes.
*/
- public ITmfFilterTreeNode[] getChildren();
+ public @NonNull ITmfFilterTreeNode[] getChildren();
/**
* <h4>Get the node by index</h4>
import java.util.Arrays;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
/**
}
@Override
- public ITmfFilterTreeNode[] getChildren() {
- return children.toArray(new ITmfFilterTreeNode[0]);
+ public @NonNull ITmfFilterTreeNode[] getChildren() {
+ return children.toArray(new @NonNull ITmfFilterTreeNode[0]);
}
@Override
package org.eclipse.tracecompass.tmf.core.parsers.custom;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
* Trace definition
*/
public CustomEventType(CustomTraceDefinition definition) {
- super(definition.definitionName, getRootField(definition));
+ super(checkNotNull(definition.definitionName), getRootField(definition));
}
private static ITmfEventField getRootField(CustomTraceDefinition definition) {
@Override
public Iterable<ITmfStateSystem> getStateSystems() {
- return checkNotNull(Collections.<ITmfStateSystem> singleton(fStateSystem));
+ ITmfStateSystemBuilder stateSystem = fStateSystem;
+ if (stateSystem == null) {
+ return Collections.EMPTY_SET;
+ }
+ return Collections.singleton(stateSystem);
}
/**
import java.util.List;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
/**
*
* @return The map of <event_type, count>, for the whole trace
*/
- Map<String, Long> getEventTypesTotal();
+ Map<@NonNull String, @NonNull Long> getEventTypesTotal();
/**
* Retrieve the number of events in the trace in a given time interval.
import java.util.Map;
import java.util.TreeMap;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
}
@Override
- public Map<String, Long> getEventTypesTotal() {
+ public Map<@NonNull String, @NonNull Long> getEventTypesTotal() {
StatsPerTypeRequest request = new StatsPerTypeRequest(trace, TmfTimeRange.ETERNITY);
sendAndWait(request);
- Map<String, Long> stats = request.getResults();
- return stats;
+ return request.getResults();
}
@Override
private class StatsPerTypeRequest extends TmfEventRequest {
/* Map in which the results are saved */
- private final Map<String, Long> stats;
+ private final Map<@NonNull String, @NonNull Long> stats;
public StatsPerTypeRequest(ITmfTrace trace, TmfTimeRange range) {
super(trace.getEventType(), range, 0, ITmfEventRequest.ALL_DATA,
this.stats = new HashMap<>();
}
- public Map<String, Long> getResults() {
+ public Map<@NonNull String, @NonNull Long> getResults() {
return stats;
}
}
}
- private void incrementStats(String key, long count) {
+ private void incrementStats(@NonNull String key, long count) {
if (stats.containsKey(key)) {
long curValue = checkNotNull(stats.get(key));
stats.put(key, curValue + count);
}
@Override
- public Map<String, Long> getEventTypesTotal() {
- final Map<String, Long> map = new HashMap<>();
+ public Map<@NonNull String, @NonNull Long> getEventTypesTotal() {
+ final Map<@NonNull String, @NonNull Long> map = new HashMap<>();
long endTime = typesStats.getCurrentEndTime();
try {
import java.io.IOException;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
import org.eclipse.tracecompass.tmf.core.component.TmfComponent;
import org.eclipse.tracecompass.tmf.core.event.matching.ITmfEventMatching;
* file
* @return The synchronization object
*/
- public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final Collection<ITmfTrace> traces, boolean doSync) {
+ public static SynchronizationAlgorithm synchronizeTraces(final File syncFile,
+ final Collection<@NonNull ITmfTrace> traces, boolean doSync) {
SynchronizationAlgorithm syncAlgo;
if (doSync) {
* file
* @return The synchronization object
*/
- public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final Collection<ITmfTrace> traces, SynchronizationAlgorithm algo, boolean doSync) {
+ public static SynchronizationAlgorithm synchronizeTraces(final File syncFile,
+ final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm algo, boolean doSync) {
SynchronizationAlgorithm syncAlgo;
if (doSync) {
return null;
}
- private static SynchronizationAlgorithm synchronize(final File syncFile, final Collection<ITmfTrace> traces, SynchronizationAlgorithm syncAlgo) {
+ private static SynchronizationAlgorithm synchronize(final File syncFile,
+ final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm syncAlgo) {
ITmfEventMatching matching = new TmfEventMatching(traces, syncAlgo);
matching.matchEvents();
package org.eclipse.tracecompass.tmf.core.trace;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
Set<@NonNull T> modules = new HashSet<>();
for (IAnalysisModule module : analysisModules) {
if (moduleClass.isAssignableFrom(module.getClass())) {
- modules.add(moduleClass.cast(module));
+ modules.add(checkNotNull(moduleClass.cast(module)));
}
}
return modules;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentContext;
*
* @return The array of contained traces
*/
- public List<ITmfTrace> getTraces() {
+ public List<@NonNull ITmfTrace> getTraces() {
return getChildren(ITmfTrace.class);
}
final File syncFile = (syncDirectory != null) ? new File(syncDirectory + File.separator + SYNCHRONIZATION_FILE_NAME) : null;
- final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Collections.<ITmfTrace> singleton(this), doSync);
+ final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Collections.singleton(this), doSync);
final TmfTraceSynchronizedSignal signal = new TmfTraceSynchronizedSignal(this, syncAlgo);
package org.eclipse.tracecompass.tmf.core.trace.text;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
private TextTraceEventContent(@NonNull String fieldName) {
fName = fieldName;
fValue = null;
- fFields = checkNotNull(Collections.EMPTY_LIST);
+ fFields = Collections.EMPTY_LIST;
}
// ------------------------------------------------------------------------
*/
public class CommandResultTest {
- private static final String @NonNull [] CMD_OUTPUT = { "This", "is", "the", "output" };
- private static final String @NonNull [] CMD_NO_ERROR_OUTPUT = {};
- private static final String @NonNull [] CMD_ERROR_OUTPUT = { "This", "is", "the", "error", "output" };
+ private static final @NonNull String @NonNull [] CMD_OUTPUT = { "This", "is", "the", "output" };
+ private static final @NonNull String @NonNull [] CMD_NO_ERROR_OUTPUT = {};
+ private static final @NonNull String @NonNull [] CMD_ERROR_OUTPUT = { "This", "is", "the", "error", "output" };
/**
* Test suite for the {@link CommandResult} class
private static final boolean IS_UNIX = !Platform.getOS().equals(Platform.OS_WIN32);
- private static final String @NonNull [] CMD_INPUT_UNIX = { "ls", "-l" };
- private static final String @NonNull [] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
- private static final String @NonNull [] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
+ private static final @NonNull String @NonNull [] CMD_INPUT_UNIX = { "ls", "-l" };
+ private static final @NonNull String @NonNull [] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
+ private static final @NonNull String @NonNull [] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
private static final IRemoteConnection LOCAL_CONNECTION = TmfRemoteConnectionFactory.getLocalConnection();
private static final RemoteSystemProxy LOCAL_PROXY = new RemoteSystemProxy(checkNotNull(LOCAL_CONNECTION));
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput;
import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandResult;
import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
/**
* Command shell stub
*/
+@NonNullByDefault
public class TestCommandShell implements ICommandShell {
/** If the shell is connected */
}
@Override
- public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor) throws ExecutionException {
+ public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor) throws ExecutionException {
return executeCommand(command, monitor, null);
}
@Override
- public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor, ICommandOutputListener listener) throws ExecutionException {
+ public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor,
+ @Nullable ICommandOutputListener listener) throws ExecutionException {
if (fIsConnected) {
- return createCommandResult(0, new String[0], new String[0]);
+ return createCommandResult(0, new @NonNull String[0], new @NonNull String[0]);
}
- return createCommandResult(1, new String[0], new String[0]);
+ return createCommandResult(1, new @NonNull String[0], new @NonNull String[0]);
}
@Override
* THe error output as an array of strings
* @return {@link ICommandResult} instance
*/
- @NonNullByDefault
- protected ICommandResult createCommandResult(int result, String[] output, String[] errorOutput) {
+ protected ICommandResult createCommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) {
return new CommandResult(result, output, errorOutput);
}
-}
\ No newline at end of file
+}
**********************************************************************/
package org.eclipse.tracecompass.internal.tmf.remote.core.shell;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandResult;
* @param errorOutput
* THe error output as an array of strings
*/
- public CommandResult(int result, String[] output, String[] errorOutput) {
+ public CommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) {
fResult = result;
- fOutput = checkNotNull(ImmutableList.copyOf(output));
- fErrorOutput = checkNotNull(ImmutableList.copyOf(errorOutput));
+ fOutput = ImmutableList.copyOf(output);
+ fErrorOutput = ImmutableList.copyOf(errorOutput);
}
// ------------------------------------------------------------------------
}
} catch (OperationCanceledException e) {
} catch (InterruptedException e) {
- return new CommandResult(1, new String[0], new String[] {e.getMessage()});
+ return new CommandResult(1, new @NonNull String[0],
+ new @NonNull String[] { checkNotNull(e.getMessage()) });
} finally {
stdout.stop();
stderr.stop();
process.destroy();
}
}
- return new CommandResult(1, new String[0], new String[] {"cancelled"}); //$NON-NLS-1$
+ return new CommandResult(1, new @NonNull String[0], new @NonNull String[] { "cancelled" }); //$NON-NLS-1$
}
});
result = origResult;
stdout = origStdout;
stderr = origStderr;
- String[] output = splitLines(stdout);
- String[] error = splitLines(stderr);
+ @NonNull String[] output = splitLines(stdout);
+ @NonNull String[] error = splitLines(stderr);
return new CommandResult(result, output, error);
}
- private static String @NonNull [] splitLines(String output) {
- return checkNotNull(output.split("\\r?\\n")); //$NON-NLS-1$
+ private static @NonNull String @NonNull [] splitLines(String output) {
+ return output.split("\\r?\\n"); //$NON-NLS-1$
}
}
// Add local services
IRemoteServicesManager manager = getService(IRemoteServicesManager.class);
if (manager != null) {
- CONNECTION_FACTORIES.put(manager.getLocalConnectionType().getId(), new LocalConnectionFactory());
+ IRemoteConnectionType type = manager.getLocalConnectionType();
+ if (type != null) {
+ CONNECTION_FACTORIES.put(checkNotNull(type.getId()), new LocalConnectionFactory());
+ }
}
}
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement;
import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.importexport.ManifestReader;
private static final String SCHEMA_FOLDER_NAME = "schema"; //$NON-NLS-1$
private static final String PROFILES_SCHEMA_FILE_NAME = "remote-profile.xsd"; //$NON-NLS-1$
- private static final TracePackageElement[] EMPTY_ARRAY = new TracePackageElement[0];
+ private static final @NonNull TracePackageElement @NonNull [] EMPTY_ARRAY =
+ new @NonNull TracePackageElement[0];
/**
* Validate the content of the profiles file from an input stream
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
}
@Override
- public ITmfFilterTreeNode[] getChildren() {
+ public @NonNull ITmfFilterTreeNode[] getChildren() {
return null;
}
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
private static final String fTestName = "ColumnDataProviderTest";
- private final String fTypeId1 = "Some type1";
- private final String fTypeId2 = "Some type2";
+ private final @NonNull String fTypeId1 = "Some type1";
+ private final @NonNull String fTypeId2 = "Some type2";
private final String fLabel0 = "label1";
private final String fLabel1 = "label2";
import java.util.Iterator;
import java.util.Vector;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
private static final String fTestName = "StatisticsDataTest";
- private final String fTypeId1 = "Some type1";
- private final String fTypeId2 = "Some type2";
+ private final @NonNull String fTypeId1 = "Some type1";
+ private final @NonNull String fTypeId2 = "Some type2";
private final String fLabel0 = "label1";
private final String fLabel1 = "label2";
import java.util.Arrays;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
private static final String fTestName = "TreeContentProviderTest";
- private final String fTypeId1 = "Some type1";
- private final String fTypeId2 = "Some type2";
+ private final @NonNull String fTypeId1 = "Some type1";
+ private final @NonNull String fTypeId2 = "Some type2";
private final String fLabel0 = "label1";
private final String fLabel1 = "label2";
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.ITracePackageConstants;
import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement;
private static final String SCHEMA_FOLDER_NAME = "schema"; //$NON-NLS-1$
private static final String EXPORT_MANIFEST_SCHEMA_FILE_NAME = "export-manifest.xsd"; //$NON-NLS-1$
- private static final TracePackageElement [] EMPTY_ARRAY = new TracePackageElement[0];
+ private static final @NonNull TracePackageElement @NonNull [] EMPTY_ARRAY =
+ new @NonNull TracePackageElement[0];
/**
* Validate the content of a manifest from an input stream
traces.add((TmfTraceElement) sel);
}
}
- TmfTraceElement[] result = new TmfTraceElement[traces.size()];
- traces.toArray(result);
- return result;
+ return traces.toArray(new @NonNull TmfTraceElement[0]);
}
/**
traces.add((TmfTraceElement) sel);
}
}
- TmfTraceElement[] result = new TmfTraceElement[traces.size()];
- traces.toArray(result);
- return result;
+ return traces.toArray(new @NonNull TmfTraceElement[0]);
}
}
@Override
public Object getPropertyValue(Object id) {
+ if (!(id instanceof String)) {
+ return null;
+ }
return event.getCustomAttribute((String) id);
}
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterRootNode;
*
* @return The array of filters
*/
- public static ITmfFilterTreeNode[] getSavedFilters() {
+ public static @NonNull ITmfFilterTreeNode[] getSavedFilters() {
return fRoot.clone().getChildren();
}