package org.eclipse.tracecompass.analysis.os.linux.ui.views.cpuusage;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
if (entry.getKey().equals(stringSelectedThread)) {
/* This is the total cpu usage for a thread */
- fYValues.get(entry.getKey())[i] = (double) cpuEntry / (double) (time - prevTime) * 100;
+ double[] key = checkNotNull(fYValues.get(entry.getKey()));
+ key[i] = (double) cpuEntry / (double) (time - prevTime) * 100;
}
}
- fYValues.get(Messages.CpuUsageXYViewer_Total)[i] = (double) totalCpu / (double) (time - prevTime) * 100;
+ double[] key = checkNotNull(fYValues.get(Messages.CpuUsageXYViewer_Total));
+ key[i] = (double) totalCpu / (double) (time - prevTime) * 100;
prevTime = time;
}
for (Entry<String, double[]> entry : fYValues.entrySet()) {
String key = "test";
fixture.addEnvironmentVar(key, key);
String result = fixture.getEnvironment().get(key);
+ assertNotNull(result);
assertTrue(result.equals(key));
}
return false;
}
IDeclaration field2 = other.fFields.get(field.getKey());
- if (!field2.isBinaryEquivalent(field.getValue())) {
+ if ((field2 == null) || (!field2.isBinaryEquivalent(field.getValue()))) {
return false;
}
}
* @return The list of event declarations
*/
public Collection<IEventDeclaration> getEventDeclarations(Long streamId) {
- return fStreams.get(streamId).getEventDeclarations();
+ CTFStream stream = fStreams.get(streamId);
+ if (stream == null) {
+ return null;
+ }
+ return stream.getEventDeclarations();
}
/**
* The file must exist
*/
public void addStream(long id, File streamFile) throws CTFException {
- CTFStream stream = null;
final File file = streamFile;
if (file == null) {
throw new CTFException("cannot create a stream with no file"); //$NON-NLS-1$
}
- if (fStreams.containsKey(id)) {
- stream = fStreams.get(id);
- } else {
+ CTFStream stream = fStreams.get(id);
+ if (stream == null) {
stream = new CTFStream(this);
fStreams.put(id, stream);
}
@Test
public void testLostEventsTypesInRange() {
Map<String, Long> eventsInRange = fStats.getEventTypesInRange(rangeStart, rangeEnd);
- long lostEventsInRange = eventsInRange.get(CTFStrings.LOST_EVENT_NAME);
- assertEquals(365752L, lostEventsInRange);
+ Long lostEventsInRange = eventsInRange.get(CTFStrings.LOST_EVENT_NAME);
+ assertNotNull(lostEventsInRange);
+ assertEquals(365752L, lostEventsInRange.longValue());
}
}
package org.eclipse.tracecompass.internal.tmf.ctf.core.trace.iterator;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
final int pos = fRnd.nextInt(size);
final CtfTmfContext victim = fRandomAccess.get(pos);
fRandomAccess.set(pos, context);
- CtfIterator elem = fMap.remove(victim);
+ CtfIterator elem = checkNotNull(fMap.remove(victim));
if (elem.isClosed()) {
/*
* In case the iterator streams have been closed, we need to
//-------------------------------------------------------------------------
event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[0];
adapter = event.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
eventSource = (TraceEventPropertySource) adapter;
assertEquals("== TRACE_DEBUG_LINE", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[1];
adapter = event.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
eventSource = (TraceEventPropertySource) adapter;
assertEquals("<= TRACE_INFO", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[2];
adapter = event.getAdapter(IPropertySource.class);
+ assertNotNull(adapter);
eventSource = (TraceEventPropertySource) adapter;
assertEquals("TRACE_DEBUG_SYSTEM", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
@Override
public synchronized ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor) throws ExecutionException {
- Map<String, ICommandResult> commands = fScenarioMap.get(fScenario);
+ Map<String, ICommandResult> commands = checkNotNull(fScenarioMap.get(fScenario));
String commandLine = command.toString();
String fullCommand = commandLine;
package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
*/
try {
for (Entry<String, Long> entry : testCases.entrySet()) {
- Assert.assertTrue(map.get(entry.getKey()).equals(entry.getValue()));
+ Long value = map.get(entry.getKey());
+ assertNotNull(value);
+ assertTrue(value.equals(entry.getValue()));
}
} catch (NullPointerException e) {
fail(e.getMessage());
package org.eclipse.tracecompass.internal.lttng2.ust.ui.views.memusage;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
time = time > traceEnd ? traceEnd : time;
for (int quark : tidQuarks) {
+ double[] values = checkNotNull(fYValues.get(quark));
try {
- yvalue = ss.querySingleState(time, fMemoryQuarks.get(quark)).getStateValue().unboxLong() / BYTES_TO_KB;
- fYValues.get(quark)[i] = yvalue;
+ Integer memQuark = checkNotNull(fMemoryQuarks.get(quark));
+ yvalue = ss.querySingleState(time, memQuark.intValue()).getStateValue().unboxLong() / BYTES_TO_KB;
+ values[i] = yvalue;
} catch (TimeRangeException e) {
- fYValues.get(quark)[i] = 0;
+ values[i] = 0;
}
}
}
package org.eclipse.tracecompass.internal.pcap.core.stream;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
*/
public synchronized @Nullable PacketStream getStream(ProtocolEndpoint endpointA, ProtocolEndpoint endpointB) {
ProtocolEndpointPair set = new ProtocolEndpointPair(endpointA, endpointB);
- int id = fIDs.get(set);
+ Integer id = checkNotNull(fIDs.get(set));
return fStreams.get(id);
}
ProtocolEndpointPair endpointSet = new ProtocolEndpointPair(newPacket);
if (!fIDs.containsKey(endpointSet)) {
fIDs.put(endpointSet, fCurrentId);
- fStreams.put(fCurrentId, new PacketStream(fProtocol, fCurrentId, endpointSet));
- fStreams.get(fCurrentId).add(packet);
+
+ PacketStream stream = new PacketStream(fProtocol, fCurrentId, endpointSet);
+ stream.add(packet);
+ fStreams.put(fCurrentId, stream);
fCurrentId++;
} else {
Integer id = fIDs.get(endpointSet);
- fStreams.get(id).add(packet);
+ checkNotNull(fStreams.get(id)).add(packet);
}
}
return;
return;
}
PcapEvent event = (PcapEvent) data;
- for (TmfPcapProtocol protocol : fBuilders.keySet()) {
- fBuilders.get(protocol).addEventToStream(event);
+ for (Map.Entry<TmfPcapProtocol, TmfPacketStreamBuilder> entry : fBuilders.entrySet()) {
+ entry.getValue().addEventToStream(event);
}
}
time = time > traceEnd ? traceEnd : time;
for (int quark : quarks) {
+ SeriesData data = checkNotNull(fSeriesData.get(quark));
try {
- yvalue = ss.querySingleState(time, fSeriesData.get(quark).getDisplayQuark()).getStateValue().unboxLong();
- fSeriesData.get(quark).setYValue(i, yvalue);
+ yvalue = ss.querySingleState(time, data.getDisplayQuark()).getStateValue().unboxLong();
+ data.setYValue(i, yvalue);
} catch (TimeRangeException e) {
- fSeriesData.get(quark).setYValue(i, 0);
+ data.setYValue(i, 0);
}
}
}
for (int quark : quarks) {
- setSeries(fSeriesData.get(quark).getSeriesName(), fSeriesData.get(quark).getYValues());
+ SeriesData data = checkNotNull(fSeriesData.get(quark));
+ setSeries(data.getSeriesName(), data.getYValues());
}
updateDisplay();
} catch (AttributeNotFoundException | StateValueTypeException e) {
package org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
int value = tcEvent.getValue();
if (entry.getType() == EntryDisplayType.DISPLAY) {
- Integer index = stateIndex.get(value);
- String rgb = stateValues.get(index).getStateString();
+ Integer index = checkNotNull(stateIndex.get(value));
+ String rgb = stateValues.get(index.intValue()).getStateString();
return rgb;
}
return null;
Map<String, TmfAnalysisRequirement> requirements = new HashMap<>();
/* Event type requirement and values */
- requirements.put(EVENT_TYPE, new TmfAnalysisRequirement(EVENT_TYPE));
- requirements.get(EVENT_TYPE).addValue(EXIT_SYSCALL, ValuePriorityLevel.MANDATORY);
- requirements.get(EVENT_TYPE).addValue(SCHED_SWITCH, ValuePriorityLevel.MANDATORY);
- requirements.get(EVENT_TYPE).addValue(SCHED_WAKEUP, ValuePriorityLevel.MANDATORY);
+ TmfAnalysisRequirement eventReqs = new TmfAnalysisRequirement(EVENT_TYPE);
+ eventReqs.addValue(EXIT_SYSCALL, ValuePriorityLevel.MANDATORY);
+ eventReqs.addValue(SCHED_SWITCH, ValuePriorityLevel.MANDATORY);
+ eventReqs.addValue(SCHED_WAKEUP, ValuePriorityLevel.MANDATORY);
+ requirements.put(EVENT_TYPE, eventReqs);
/* Field type requirement and values */
- requirements.put(FIELD_TYPE, new TmfAnalysisRequirement(FIELD_TYPE));
- requirements.get(FIELD_TYPE).addValue(PID, ValuePriorityLevel.MANDATORY);
- requirements.get(FIELD_TYPE).addValue(TID, ValuePriorityLevel.MANDATORY);
+ TmfAnalysisRequirement fieldReqs = new TmfAnalysisRequirement(FIELD_TYPE);
+ fieldReqs.addValue(PID, ValuePriorityLevel.MANDATORY);
+ fieldReqs.addValue(TID, ValuePriorityLevel.MANDATORY);
+ requirements.put(FIELD_TYPE, fieldReqs);
@SuppressWarnings("null")
@NonNull Collection<TmfAnalysisRequirement> values = requirements.values();
* @param provider
* The data provider
*/
- public static <T extends ITmfEvent> void register(Class<T> eventType, TmfEventProvider provider) {
- if (fProviders.get(eventType) == null) {
- fProviders.put(eventType, new ArrayList<TmfEventProvider>());
+ public static synchronized <T extends ITmfEvent> void register(Class<T> eventType, TmfEventProvider provider) {
+ List<TmfEventProvider> typeProviders = fProviders.get(eventType);
+ if (typeProviders == null) {
+ typeProviders = new ArrayList<>();
+ fProviders.put(eventType, typeProviders);
}
- fProviders.get(eventType).add(provider);
+ typeProviders.add(provider);
}
/**
* @param provider
* The data provider
*/
- public static <T extends ITmfEvent> void deregister(Class<T> eventType, TmfEventProvider provider) {
+ public static synchronized <T extends ITmfEvent> void deregister(Class<T> eventType, TmfEventProvider provider) {
List<TmfEventProvider> list = fProviders.get(eventType);
if (list != null) {
list.remove(provider);
if (!fParameterProviders.containsKey(analysisId)) {
fParameterProviders.put(analysisId, new ArrayList<Class<? extends IAnalysisParameterProvider>>());
}
- fParameterProviders.get(analysisId).add(paramProvider);
+ /* We checked via containsKey() above, get() should not return null */
+ checkNotNull(fParameterProviders.get(analysisId)).add(paramProvider);
}
}
if (!fParameterProviders.containsKey(module.getId())) {
return providerList;
}
- for (Class<? extends IAnalysisParameterProvider> providerClass : fParameterProviders.get(module.getId())) {
+ /* We checked via containsKey, get() should not return null */
+ List<Class<? extends IAnalysisParameterProvider>> parameterProviders = checkNotNull(fParameterProviders.get(module.getId()));
+ for (Class<? extends IAnalysisParameterProvider> providerClass : parameterProviders) {
try {
IAnalysisParameterProvider provider = fParamProviderInstances.get(providerClass);
if (provider == null) {
provider = providerClass.newInstance();
fParamProviderInstances.put(providerClass, provider);
}
- if (provider != null && provider.appliesToTrace(trace)) {
+ if (provider.appliesToTrace(trace)) {
providerList.add(provider);
}
} catch (IllegalArgumentException | SecurityException | InstantiationException | IllegalAccessException e) {
package org.eclipse.tracecompass.tmf.core.parsers.custom;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
}
}
} else {
- if (countMap.get(currentInput) >= currentInput.getMinCount()) {
+ if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMinCount()) {
final List<InputLine> nextInputs = currentInput.getNextInputs(countMap);
if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
for (final InputLine input : getFirstLines()) {
if (countMap.get(currentInput) == null) {
countMap.put(currentInput, 1);
} else {
- countMap.put(currentInput, countMap.get(currentInput) + 1);
+ countMap.put(currentInput, checkNotNull(countMap.get(currentInput)) + 1);
}
Iterator<InputLine> iter = countMap.keySet().iterator();
while (iter.hasNext()) {
if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
currentInput = currentInput.childrenInputs.get(0);
countMap.put(currentInput, 0);
- } else if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+ } else if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMaxCount()) {
if (currentInput.getNextInputs(countMap).size() > 0) {
currentInput = currentInput.getNextInputs(countMap).get(0);
if (countMap.get(currentInput) == null) {
final Matcher matcher = currentInput.getPattern().matcher(line);
if (matcher.matches()) {
event.processGroups(currentInput, matcher);
- countMap.put(currentInput, countMap.get(currentInput) + 1);
+ countMap.put(currentInput, checkNotNull(countMap.get(currentInput)) + 1);
if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
currentInput = currentInput.childrenInputs.get(0);
countMap.put(currentInput, 0);
- } else if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+ } else if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMaxCount()) {
if (currentInput.getNextInputs(countMap).size() > 0) {
currentInput = currentInput.getNextInputs(countMap).get(0);
if (countMap.get(currentInput) == null) {
next = next.nextInput;
}
if (parentInput != null && parentInput.level > 0) {
- int parentCount = countMap.get(parentInput);
+ int parentCount = checkNotNull(countMap.get(parentInput));
if (parentCount < parentInput.getMaxCount()) {
nextInputs.add(parentInput);
}
*/
public static List<String> getTraceCategories() {
List<String> categoryNames = new ArrayList<>();
- for (String key : TRACE_TYPES.keySet()) {
- final String categoryName = TRACE_TYPES.get(key).getCategoryName();
+ for (Map.Entry<String, TraceTypeHelper> entry : TRACE_TYPES.entrySet()) {
+ final String categoryName = entry.getValue().getCategoryName();
if (!categoryNames.contains(categoryName)) {
categoryNames.add(categoryName);
}
package org.eclipse.tracecompass.tmf.core.statistics;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
private void incrementStats(String key, long count) {
if (stats.containsKey(key)) {
- long curValue = stats.get(key);
+ long curValue = checkNotNull(stats.get(key));
stats.put(key, curValue + count);
} else {
stats.put(key, count);
}
private void incrementValue(Long key) {
- long value = results.get(key);
+ long value = checkNotNull(results.get(key));
value++;
results.put(key, value);
}
package org.eclipse.tracecompass.tmf.core.timestamp;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
}
private static String computeSubSecFormat(Map<String, String> prefsMap) {
- String sSecFormat = prefsMap.get(ITmfTimePreferencesConstants.SUBSEC);
+ String sSecFormat = checkNotNull(prefsMap.get(ITmfTimePreferencesConstants.SUBSEC));
String sSecFieldSep = prefsMap.get(ITmfTimePreferencesConstants.SSEC_DELIMITER);
String ssecFmt = sSecFormat.replaceAll(" ", sSecFieldSep); //$NON-NLS-1$
return ssecFmt;
package org.eclipse.tracecompass.internal.tmf.ui.parsers.wizards;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
}
}
} else {
- if (countMap.get(currentInput) >= currentInput.getMinCount()) {
+ if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMinCount()) {
List<InputLine> nextInputs = currentInput.getNextInputs(countMap);
if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
for (InputLine input : definition.inputs) {
if (countMap.get(currentInput) == null) {
countMap.put(currentInput, 1);
} else {
- countMap.put(currentInput, countMap.get(currentInput) + 1);
+ countMap.put(currentInput, checkNotNull(countMap.get(currentInput)) + 1);
}
Iterator<InputLine> iter = countMap.keySet().iterator();
while (iter.hasNext()) {
currentInput = currentInput.childrenInputs.get(0);
countMap.put(currentInput, 0);
} else {
- if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+ if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMaxCount()) {
if (currentInput.getNextInputs(countMap).size() > 0) {
currentInput = currentInput.getNextInputs(countMap).get(0);
if (countMap.get(currentInput) == null) {
inputText.setStyleRange(new StyleRange(rawPos, length,
COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);
- countMap.put(currentInput, countMap.get(currentInput) + 1);
+ countMap.put(currentInput, checkNotNull(countMap.get(currentInput)) + 1);
if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
currentInput = currentInput.childrenInputs.get(0);
countMap.put(currentInput, 0);
} else {
- if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+ if (checkNotNull(countMap.get(currentInput)) >= currentInput.getMaxCount()) {
if (currentInput.getNextInputs(countMap).size() > 0) {
currentInput = currentInput.getNextInputs(countMap).get(0);
if (countMap.get(currentInput) == null) {
@Override
protected Object getValue(Object element) {
- if (map.get(element) == null) {
+ ITmfTimestamp ts = map.get(element);
+ if (ts == null) {
return ""; //$NON-NLS-1$
}
- return TIME_FORMAT.format(map.get(element).normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
+ return TIME_FORMAT.format(ts.normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
}
}
@Override
protected Object getValue(Object element) {
- if (fOffsetMap.get(element) == 0) {
+ Long offset = fOffsetMap.get(element);
+ if (offset == null || offset == 0) {
return ""; //$NON-NLS-1$
}
- return OFFSET_FORMAT.format((long) fOffsetMap.get(element));
+ return OFFSET_FORMAT.format(offset.longValue());
}
}
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- if (fOffsetMap.get(element) != 0) {
- return super.getText(OFFSET_FORMAT.format((long) fOffsetMap.get(element)));
+ Long offset = fOffsetMap.get(element);
+ if (offset == null || offset == 0) {
+ return ""; //$NON-NLS-1$
}
- return ""; //$NON-NLS-1$
+ return super.getText(OFFSET_FORMAT.format(offset.longValue()));
}
});
column.setEditingSupport(new OffsetEditingSupport(fViewer.getViewer(), textCellEditor));
public static synchronized TmfProjectElement getProject(IProject project, boolean force) {
TmfProjectElement element = registry.get(project);
if (element == null && force) {
- registry.put(project, new TmfProjectElement(project.getName(), project, null));
- element = registry.get(project);
+ element = new TmfProjectElement(project.getName(), project, null);
+ registry.put(project, element);
// force the model to be populated
element.refreshChildren();
}
} else {
childrenMap.remove(name);
}
- ((TmfProjectModelElement) element).refreshChildren();
+ if (element != null) {
+ ((TmfProjectModelElement) element).refreshChildren();
+ }
}
} catch (CoreException e) {
}
// Remove traces that were unchecked (thus left in
// fPreviousTraces)
- keys = fPreviousTraces.keySet();
- for (String key : keys) {
+ for (Map.Entry<String, TmfTraceElement> entry : fPreviousTraces.entrySet()) {
ModalContext.checkCanceled(progressMonitor);
- TmfTraceElement trace = fPreviousTraces.get(key);
+ TmfTraceElement trace = entry.getValue();
subMonitor.setTaskName(Messages.SelectTracesWizardPage_TraceRemovalTask + " " + trace.getElementPath()); //$NON-NLS-1$
try {
package org.eclipse.tracecompass.tmf.ui.views.filter;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
fTypeCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- TraceTypeHelper helper = fTraceTypeMap.get(fTypeCombo.getText());
+ TraceTypeHelper helper = checkNotNull(fTraceTypeMap.get(fTypeCombo.getText()));
fNode.setTraceTypeId(helper.getTraceTypeId());
fNode.setTraceClass(helper.getTraceClass());
fNode.setName(fTypeCombo.getText());
package org.eclipse.tracecompass.tmf.ui.views.uml2sd.core;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
List<SDTimeEvent> timeArray = new ArrayList<>();
while (it.hasNext()) {
String nodeType = it.next();
- List<GraphNode> list = getNodeMap().get(nodeType);
+ List<GraphNode> list = checkNotNull(getNodeMap().get(nodeType));
for (int i = 0; i < list.size(); i++) {
Object timedNode = list.get(i);
if ((timedNode instanceof ITimeRange) && ((ITimeRange) timedNode).hasTimeInfo()) {
package org.eclipse.tracecompass.tmf.ui.views.uml2sd.core;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
public int getFirstVisibleLifeline() {
if (!hasChildren()) {
return 0;
- } else if (getIndexes().get(Lifeline.LIFELINE_TAG) != null) {
- return getIndexes().get(Lifeline.LIFELINE_TAG).intValue();
}
- return 0;
+ Integer ret = getIndexes().get(Lifeline.LIFELINE_TAG);
+ return (ret == null ? 0 : ret.intValue());
}
/**
public int getFirstVisibleSyncMessage() {
if (!hasChildren()) {
return 0;
- } else if (getIndexes().get(SyncMessage.SYNC_MESS_TAG) != null) {
- return getIndexes().get(SyncMessage.SYNC_MESS_TAG).intValue();
}
- return 0;
+ Integer ret = getIndexes().get(SyncMessage.SYNC_MESS_TAG);
+ return (ret == null ? 0 : ret.intValue());
}
/**
public int getFirstVisibleSyncMessageReturn() {
if (!hasChildren()) {
return 0;
- } else if (getIndexes().get(SyncMessageReturn.SYNC_MESS_RET_TAG) != null) {
- return getIndexes().get(SyncMessageReturn.SYNC_MESS_RET_TAG).intValue();
}
- return 0;
+ Integer ret = getIndexes().get(SyncMessageReturn.SYNC_MESS_RET_TAG);
+ return (ret == null ? 0 : ret.intValue());
}
/**
public int getFirstVisibleAsyncMessage() {
if (!hasChildren()) {
return 0;
- } else if (getIndexes().get(AsyncMessage.ASYNC_MESS_TAG) != null) {
- return getIndexes().get(AsyncMessage.ASYNC_MESS_TAG).intValue();
}
- return 0;
+ Integer ret = getIndexes().get(AsyncMessage.ASYNC_MESS_TAG);
+ return (ret == null ? 0 : ret.intValue());
}
/**
public int getFirstVisibleAsyncMessageReturn() {
if (!hasChildren()) {
return 0;
- } else if (getIndexes().get(AsyncMessageReturn.ASYNC_MESS_RET_TAG) != null) {
- return getIndexes().get(AsyncMessageReturn.ASYNC_MESS_RET_TAG).intValue();
}
- return 0;
+ Integer ret = getIndexes().get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
+ return (ret == null ? 0 : ret.intValue());
}
/**
if (getIndexes().size() == 0) {
return;
}
- int lifeLineDrawIndex = getIndexes().get(Lifeline.LIFELINE_TAG).intValue();
- for (int i = lifeLineDrawIndex; i < getNodeMap().get(Lifeline.LIFELINE_TAG).size(); i = i + lifelineArryStep) {
- Lifeline toDraw = (Lifeline) getNodeMap().get(Lifeline.LIFELINE_TAG).get(i);
+ int lifeLineDrawIndex = checkNotNull(getIndexes().get(Lifeline.LIFELINE_TAG)).intValue();
+ List<GraphNode> nodeList = checkNotNull(getNodeMap().get(Lifeline.LIFELINE_TAG));
+ for (int i = lifeLineDrawIndex; i < nodeList.size(); i = i + lifelineArryStep) {
+ Lifeline toDraw = (Lifeline) nodeList.get(i);
if (toDraw.getX() - Metrics.LIFELINE_SPACING / 2 > context.getContentsX() + context.getVisibleWidth()) {
break;
}
List<SDTimeEvent> timeArray = super.buildTimeArray();
fExecutionOccurrencesWithTime = null;
if (getLifelines() != null) {
- for (int i = 0; i < getNodeMap().get(Lifeline.LIFELINE_TAG).size(); i++) {
- Lifeline lifeline = (Lifeline) getNodeMap().get(Lifeline.LIFELINE_TAG).get(i);
+ List<GraphNode> nodeList = checkNotNull(getNodeMap().get(Lifeline.LIFELINE_TAG));
+ for (int i = 0; i < nodeList.size(); i++) {
+ Lifeline lifeline = (Lifeline) nodeList.get(i);
if (lifeline.hasTimeInfo() && lifeline.getExecutions() != null) {
for (Iterator<GraphNode> j = lifeline.getExecutions().iterator(); j.hasNext();) {
GraphNode o = j.next();
package org.eclipse.tracecompass.tmf.ui.views.uml2sd.core;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
GraphNode node = null;
for (Map.Entry<String, List<GraphNode>> entry : fNodes.entrySet()) {
List<GraphNode> list = entry.getValue();
- int index = fIndexes.get(entry.getKey()).intValue();
+ int index = checkNotNull(fIndexes.get(entry.getKey())).intValue();
node = getNodeFromListAt(x, y, list, index);
if (toReturn == null) {
toReturn = node;
for (Map.Entry<String, List<GraphNode>> entry : fNodes.entrySet()) {
String nodeType = entry.getKey();
int direction = 1;
- int drawIndex = fIndexes.get(nodeType).intValue();
-
+ int drawIndex = checkNotNull(fIndexes.get(nodeType)).intValue();
if ((entry.getValue() != null) && (entry.getValue().size() > 1)) {
if (entry.getValue().get(drawIndex).positiveDistanceToPoint(x, y)) {
direction = -1;
direction = 1;
}
- if ((direction == -1) && (fBackwardNodes.get(nodeType) != null)) {
+ List<GraphNode> nodes = fBackwardNodes.get(nodeType);
+ if ((direction == -1) && (nodes != null)) {
GraphNode currentNode = entry.getValue().get(drawIndex);
- drawIndex = Arrays.binarySearch(fBackwardNodes.get(nodeType).toArray(new GraphNode[fBackwardNodes.get(nodeType).size()]),
+ drawIndex = Arrays.binarySearch(nodes.toArray(new GraphNode[nodes.size()]),
entry.getValue().get(drawIndex), currentNode.getBackComparator());
- entry.setValue(fBackwardNodes.get(nodeType));
+ entry.setValue(nodes);
if (drawIndex < 0) {
drawIndex = 0;
direction = 1;
entry.setValue(fForwardNodes.get(nodeType));
if ((fBackwardNodes.get(nodeType) != null) && (direction == -1)) {
- int index = fIndexes.get(nodeType).intValue();
+ int index = checkNotNull(fIndexes.get(nodeType)).intValue();
List<GraphNode> list = entry.getValue();
- List<GraphNode> backList = fBackwardNodes.get(nodeType);
+ List<GraphNode> backList = checkNotNull(fBackwardNodes.get(nodeType));
GraphNode currentNode = (backList.get(index));
if (index > 0) {
index = Arrays.binarySearch(list.toArray(new GraphNode[list.size()]), backList.get(index), currentNode.getComparator());
String nodeType = entry.getKey();
boolean sort = entry.getValue().booleanValue();
if (sort) {
- GraphNode[] temp = fForwardNodes.get(nodeType).toArray(new GraphNode[fForwardNodes.get(nodeType).size()]);
- GraphNode node = fNodes.get(nodeType).get(0);
+ List<GraphNode> forwardNodes = checkNotNull(fForwardNodes.get(nodeType));
+ GraphNode[] temp = forwardNodes.toArray(new GraphNode[forwardNodes.size()]);
+ GraphNode node = checkNotNull(fNodes.get(nodeType)).get(0);
Arrays.sort(temp, node.getComparator());
entry.setValue(Boolean.FALSE);
fNodes.put(nodeType, Arrays.asList(temp));
String nodeType = entry.getKey();
boolean sort = entry.getValue().booleanValue();
if (sort) {
- GraphNode[] temp = fBackwardNodes.get(nodeType).toArray(new GraphNode[fBackwardNodes.get(nodeType).size()]);
- GraphNode node = fNodes.get(nodeType).get(0);
+ List<GraphNode> backwardNodes = checkNotNull(fBackwardNodes.get(nodeType));
+ GraphNode[] temp = backwardNodes.toArray(new GraphNode[backwardNodes.size()]);
+ GraphNode node = checkNotNull(fNodes.get(nodeType)).get(0);
Arrays.sort(temp, node.getBackComparator());
entry.setValue(Boolean.FALSE);
fBackwardNodes.put(nodeType, Arrays.asList(temp));
while (it3.hasNext()) {
count = 0;
Object nodeType = it3.next();
- GraphNode node = fNodes.get(nodeType).get(0);
+ GraphNode node = checkNotNull(fNodes.get(nodeType)).get(0);
context.setFont(SDViewPref.getInstance().getFont(node.fPrefId));
- int index = fIndexes.get(nodeType).intValue();
+ int index = checkNotNull(fIndexes.get(nodeType)).intValue();
count = drawNodes(context, fNodes.get(nodeType), index, arrayStep);
if (TmfUiTracer.isDisplayTraced()) {
TmfUiTracer.traceDisplay(count + " " + nodeType + " drawn, starting from index " + index + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (!hasChildren()) {
return 0;
}
- if (getIndexes().get(BasicExecutionOccurrence.EXEC_OCC_TAG) != null) {
- return getIndexes().get(BasicExecutionOccurrence.EXEC_OCC_TAG).intValue();
- }
- return 0;
+ Integer ret = getIndexes().get(BasicExecutionOccurrence.EXEC_OCC_TAG);
+ return (ret == null ? 0 : ret.intValue());
}
/**
for (int i = 0; i < FONT_LIST.length; i++) {
FontData fontData = PreferenceConverter.getFontData(fPrefStore, FONT_LIST[i]);
- if (fFontPref.get(FONT_LIST[i]) != null) {
- fFontPref.get(FONT_LIST[i]).dispose();
+ IFont font = fFontPref.get(FONT_LIST[i]);
+ if (font != null) {
+ font.dispose();
}
fFontPref.put(FONT_LIST[i], new FontImpl(display, fontData));
}
for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX);
- if (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) {
- fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX).dispose();
+ IColor color = fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX);
+ if (color != null) {
+ color.dispose();
}
fBackColorPref.put(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX);
- if (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) {
- fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX).dispose();
+ IColor color = fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX);
+ if (color != null) {
+ color.dispose();
}
fForeColorPref.put(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX);
- if (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) {
- fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX).dispose();
+ IColor color = fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX);
+ if (color != null) {
+ color.dispose();
}
fTextColorPref.put(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}