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;
import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
private @Nullable PcapEndpoint fSourceEndpoint;
private @Nullable PcapEndpoint fDestinationEndpoint;
- private @Nullable ImmutableMap<String, String> fFields;
+ private @Nullable Map<String, String> fFields;
/**
* Constructor of the Pcap Packet class.
// TODO microsec
@Override
public Map<String, String> getFields() {
- ImmutableMap<String, String> map = fFields;
+ Map<String, String> map = fFields;
if (map == null) {
- @SuppressWarnings("null")
- @NonNull ImmutableMap<String, String> newMap = ImmutableMap.<String, String> builder()
- .put("Frame", String.valueOf(fPacketIndex)) //$NON-NLS-1$
- .put("Frame Length", String.valueOf(fOriginalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
- .put("Capture Length", String.valueOf(fIncludedLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
- .put("Capture Time", ConversionHelper.toGMTTime(fTimestamp, getTimestampScale())) //$NON-NLS-1$
- .build();
- fFields = newMap;
- return newMap;
+ ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
+ builder.put("Frame", String.valueOf(fPacketIndex)); //$NON-NLS-1$
+ builder.put("Frame Length", String.valueOf(fOriginalLength) + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$
+ builder.put("Capture Length", String.valueOf(fIncludedLength) + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$
+ builder.put("Capture Time", ConversionHelper.toGMTTime(fTimestamp, getTimestampScale())); //$NON-NLS-1$
+
+ fFields = NonNullUtils.checkNotNull(builder.build());
+ return fFields;
}
return map;
}
return false;
}
PcapPacket other = (PcapPacket) obj;
- final Packet child = fChildPacket;
- if (child != null) {
- if (!child.equals(other.fChildPacket)) {
- return false;
- }
- } else {
- if (other.fChildPacket != null) {
- return false;
- }
+ if(!NonNullUtils.equalsNullable(fChildPacket, other.fChildPacket)){
+ return false;
}
-
if (fIncludedLength != other.fIncludedLength) {
return false;
}
if (fPacketIndex != other.fPacketIndex) {
return false;
}
- final ByteBuffer payload = fPayload;
- if (payload != null) {
- if (!payload.equals(other.fPayload)) {
- return false;
- }
- } else {
- if (other.fPayload != null) {
- return false;
- }
+ if(!NonNullUtils.equalsNullable(fPayload, other.fPayload)) {
+ return false;
}
-
if (fTimestamp != other.fTimestamp) {
return false;
}