1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation, updated as per TMF Event Model 1.0
11 * Alexandre Montplaisir - Made immutable, consolidated constructors
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.core
.event
;
16 import org
.eclipse
.core
.runtime
.PlatformObject
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
24 * A basic implementation of ITmfEvent.
26 * @author Francois Chouinard
33 public class TmfEvent
extends PlatformObject
implements ITmfEvent
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 private final ITmfTrace fTrace
;
40 private final long fRank
;
41 private final @NonNull ITmfTimestamp fTimestamp
;
42 private final ITmfEventType fType
;
43 private final ITmfEventField fContent
;
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
50 * Default constructor. Is required for extension points, but should not be
53 * @deprecated Do not use, extension-point use only. Use
54 * {@link #TmfEvent(ITmfTrace, long, ITmfTimestamp, ITmfEventType, ITmfEventField)}
59 this(null, ITmfContext
.UNKNOWN_RANK
, null, null, null);
68 * the event rank (in the trace). You can use
69 * {@link ITmfContext#UNKNOWN_RANK} as default value
75 * the event content (payload)
77 public TmfEvent(final ITmfTrace trace
,
79 final ITmfTimestamp timestamp
,
80 final ITmfEventType type
,
81 final ITmfEventField content
) {
84 if (timestamp
!= null) {
85 fTimestamp
= timestamp
;
87 fTimestamp
= TmfTimestamp
.ZERO
;
96 * @param event the original event
98 public TmfEvent(final @NonNull ITmfEvent event
) {
99 fTrace
= event
.getTrace();
100 fRank
= event
.getRank();
101 fTimestamp
= event
.getTimestamp();
102 fType
= event
.getType();
103 fContent
= event
.getContent();
106 // ------------------------------------------------------------------------
108 // ------------------------------------------------------------------------
111 public ITmfTrace
getTrace() {
112 ITmfTrace trace
= fTrace
;
114 throw new IllegalStateException("Null traces are only allowed on special kind of events and getTrace() should not be called on them"); //$NON-NLS-1$
120 public long getRank() {
125 public ITmfTimestamp
getTimestamp() {
130 public ITmfEventType
getType() {
135 public ITmfEventField
getContent() {
139 // ------------------------------------------------------------------------
141 // ------------------------------------------------------------------------
144 public int hashCode() {
145 final int prime
= 31;
147 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.hashCode());
148 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
149 result
= prime
* result
+ fTimestamp
.hashCode();
150 result
= prime
* result
+ ((fType
== null) ?
0 : fType
.hashCode());
151 result
= prime
* result
+ ((fContent
== null) ?
0 : fContent
.hashCode());
156 public boolean equals(final Object obj
) {
163 if (!(obj
instanceof TmfEvent
)) {
166 final TmfEvent other
= (TmfEvent
) obj
;
167 if (fTrace
== null) {
168 if (other
.fTrace
!= null) {
171 } else if (!fTrace
.equals(other
.fTrace
)) {
174 if (fRank
!= other
.fRank
) {
177 if (!fTimestamp
.equals(other
.fTimestamp
)) {
181 if (other
.fType
!= null) {
184 } else if (!fType
.equals(other
.fType
)) {
187 if (fContent
== null) {
188 if (other
.fContent
!= null) {
191 } else if (!fContent
.equals(other
.fContent
)) {
198 @SuppressWarnings("nls")
199 public String
toString() {
200 return getClass().getSimpleName() + " [fTimestamp=" + getTimestamp()
201 + ", fTrace=" + getTrace() + ", fRank=" + getRank()
202 + ", fType=" + getType() + ", fContent=" + getContent()
This page took 0.035875 seconds and 5 git commands to generate.