final ITmfEvent event = new TmfEvent(fTrace, ITmfContext.UNKNOWN_RANK, null, null, null);
assertNotNull("getTrace", event.getTrace());
assertEquals("getRank", ITmfContext.UNKNOWN_RANK, event.getRank());
- assertNull("getTimestamp", event.getTimestamp());
+ assertEquals("getTimestamp", TmfTimestamp.ZERO, event.getTimestamp());
assertNull("getType", event.getType());
assertNull("getContent", event.getContent());
}
* @return the event timestamp
* @since 2.0
*/
- ITmfTimestamp getTimestamp();
+ @NonNull ITmfTimestamp getTimestamp();
/**
* @return the event type
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
private final ITmfTrace fTrace;
private final long fRank;
- private final ITmfTimestamp fTimestamp;
+ private final @NonNull ITmfTimestamp fTimestamp;
private final ITmfEventType fType;
private final ITmfEventField fContent;
final ITmfEventField content) {
fTrace = trace;
fRank = rank;
- fTimestamp = timestamp;
+ if (timestamp != null) {
+ fTimestamp = timestamp;
+ } else {
+ fTimestamp = TmfTimestamp.ZERO;
+ }
fType = type;
fContent = content;
}
int result = 1;
result = prime * result + ((fTrace == null) ? 0 : fTrace.hashCode());
result = prime * result + (int) (fRank ^ (fRank >>> 32));
- result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
+ result = prime * result + fTimestamp.hashCode();
result = prime * result + ((fType == null) ? 0 : fType.hashCode());
result = prime * result + ((fContent == null) ? 0 : fContent.hashCode());
return result;
if (fRank != other.fRank) {
return false;
}
- if (fTimestamp == null) {
- if (other.fTimestamp != null) {
- return false;
- }
- } else if (!fTimestamp.equals(other.fTimestamp)) {
+ if (!fTimestamp.equals(other.fTimestamp)) {
return false;
}
if (fType == null) {
protected static final String NO_MESSAGE = ""; //$NON-NLS-1$
/** Replacement for the super-class' timestamp field */
- private ITmfTimestamp customEventTimestamp;
+ private @NonNull ITmfTimestamp customEventTimestamp;
/** Replacement for the super-class' content field */
private ITmfEventField customEventContent;
super(null, ITmfContext.UNKNOWN_RANK, null, null, null);
fDefinition = definition;
fData = new HashMap<>();
+ customEventTimestamp = TmfTimestamp.ZERO;
}
/**
fData = new HashMap<>();
/* Set our overridden fields */
- customEventTimestamp = timestamp;
+ if (timestamp == null) {
+ customEventTimestamp = TmfTimestamp.ZERO;
+ } else {
+ customEventTimestamp = timestamp;
+ }
customEventContent = null;
customEventType = type;
}
* @param timestamp
* The new timestamp
*/
- protected void setTimestamp(ITmfTimestamp timestamp) {
+ protected void setTimestamp(@NonNull ITmfTimestamp timestamp) {
customEventTimestamp = timestamp;
}
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((fDefinition == null) ? 0 : fDefinition.hashCode());
- result = prime * result + ((customEventTimestamp == null) ? 0 : customEventTimestamp.hashCode());
+ result = prime * result + customEventTimestamp.hashCode();
result = prime * result + ((customEventContent == null) ? 0 : customEventContent.hashCode());
result = prime * result + ((customEventType == null) ? 0 : customEventType.hashCode());
return result;
return false;
}
- if (customEventTimestamp == null) {
- if (other.customEventTimestamp != null) {
- return false;
- }
- } else if (!customEventTimestamp.equals(other.customEventTimestamp)) {
+ if (!customEventTimestamp.equals(other.customEventTimestamp)) {
return false;
}
import java.nio.ByteBuffer;
+import org.eclipse.jdt.annotation.NonNull;
+
/**
* A generic timestamp implementation. The timestamp is represented by the
* tuple { value, scale, precision }. By default, timestamps are scaled in
/**
* The beginning of time
*/
- public static final ITmfTimestamp BIG_BANG =
+ public static final @NonNull ITmfTimestamp BIG_BANG =
new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE);
/**
* The end of time
*/
- public static final ITmfTimestamp BIG_CRUNCH =
+ public static final @NonNull ITmfTimestamp BIG_CRUNCH =
new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE);
- /**
- * A more practical definition of "beginning of time"
- */
- public static final ITmfTimestamp PROJECT_IS_FUNDED = BIG_BANG;
-
- /**
- * A more practical definition of "end of time"
- */
- public static final ITmfTimestamp PROJECT_IS_CANNED = BIG_CRUNCH;
-
/**
* Zero
*/
- public static final ITmfTimestamp ZERO =
+ public static final @NonNull ITmfTimestamp ZERO =
new TmfTimestamp(0, 0);
// ------------------------------------------------------------------------
for (int i = 0; i < length; i++) {
final ITmfEvent event = expContext.getEvent(i);
- if (event != null && event.getTimestamp() != null) {
+ if (event != null) {
final ITmfTimestamp otherTS = event.getTimestamp();
if (otherTS.compareTo(timestamp) < 0) {
trace = i;
public OneEventRequestPerTs(ITmfTimestamp ts) {
super(CtfTmfEvent.class,
- new TmfTimeRange(ts, TmfTimestamp.PROJECT_IS_CANNED),
+ new TmfTimeRange(ts, TmfTimestamp.BIG_CRUNCH),
0, 1, ExecutionType.FOREGROUND);
}
@Override
public Object getPropertyValue(Object id) {
- if (id.equals(ID_TIMESTAMP) && fEvent.getTimestamp() != null) {
+ if (id.equals(ID_TIMESTAMP)) {
return new TimestampPropertySource(fEvent.getTimestamp());
} else if (id.equals(ID_TYPE) && fEvent.getType() != null) {
return fEvent.getType().toString();