Move alltests plugin to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / TmfLostEvent.java
CommitLineData
534c96ce 1/*******************************************************************************
61759503 2 * Copyright (c) 2012, 2013 Ericsson
534c96ce
FC
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
d6b40e87 11 * Alexandre Montplaisir - Made immutable
534c96ce
FC
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.tmf.core.event;
15
3bd46eef
AM
16import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
17import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
534c96ce
FC
18import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
19
20/**
21 * A basic implementation of ITmfLostEvent.
22 *
23 * @author Francois Chouinard
24 * @version 1.0
77c4a6df 25 * @since 1.2
534c96ce
FC
26*/
27public class TmfLostEvent extends TmfEvent implements ITmfLostEvent {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
d6b40e87
AM
33 private final TmfTimeRange fTimeRange;
34 private final long fNbLostEvents;
534c96ce
FC
35
36 // ------------------------------------------------------------------------
37 // Constructors
38 // ------------------------------------------------------------------------
39
534c96ce
FC
40 /**
41 * Full constructor
42 *
d6b40e87
AM
43 * @param trace
44 * the parent trace
45 * @param rank
46 * the event rank (in the trace)
47 * @param timestamp
48 * the event timestamp
49 * @param source
50 * the event source
51 * @param type
52 * the event type
53 * @param reference
54 * the event reference
55 * @param timeRange
56 * the 'problematic' time range
57 * @param nbLostEvents
58 * the number of lost events in the time range
3bd46eef 59 * @since 2.0
534c96ce 60 */
d6b40e87
AM
61 public TmfLostEvent(final ITmfTrace trace,
62 final long rank,
63 final ITmfTimestamp timestamp,
64 final String source,
65 final ITmfEventType type,
66 final String reference,
67 final TmfTimeRange timeRange,
68 final long nbLostEvents) {
534c96ce
FC
69 super(trace, rank, timestamp, source, type, null, reference);
70 fTimeRange = timeRange;
71 fNbLostEvents = nbLostEvents;
72 }
73
534c96ce
FC
74 // ------------------------------------------------------------------------
75 // ITmfLostEvent
76 // ------------------------------------------------------------------------
77
3bd46eef
AM
78 /**
79 * @since 2.0
80 */
534c96ce
FC
81 @Override
82 public TmfTimeRange getTimeRange() {
83 return fTimeRange;
84 }
85
534c96ce
FC
86 @Override
87 public long getNbLostEvents() {
88 return fNbLostEvents;
89 }
90
534c96ce
FC
91 // ------------------------------------------------------------------------
92 // Object
93 // ------------------------------------------------------------------------
94
534c96ce
FC
95 @Override
96 public int hashCode() {
97 final int prime = 31;
98 int result = super.hashCode();
99 result = prime * result + (int) (fNbLostEvents ^ (fNbLostEvents >>> 32));
100 result = prime * result + ((fTimeRange == null) ? 0 : fTimeRange.hashCode());
101 return result;
102 }
103
534c96ce
FC
104 @Override
105 public boolean equals(Object obj) {
106 if (this == obj) {
107 return true;
108 }
109 if (!super.equals(obj)) {
110 return false;
111 }
112 if (!(obj instanceof TmfLostEvent)) {
113 return false;
114 }
115 TmfLostEvent other = (TmfLostEvent) obj;
116 if (fNbLostEvents != other.fNbLostEvents) {
117 return false;
118 }
119 if (fTimeRange == null) {
120 if (other.fTimeRange != null) {
121 return false;
122 }
123 } else if (!fTimeRange.equals(other.fTimeRange)) {
124 return false;
125 }
126 return true;
127 }
128
534c96ce
FC
129 @Override
130 @SuppressWarnings("nls")
131 public String toString() {
d6b40e87
AM
132 return getClass().getSimpleName() + " [Event=" + super.toString() +
133 ", fTimeRange=" + fTimeRange + ", fNbLostEvents=" + fNbLostEvents + "]";
534c96ce
FC
134 }
135
136}
This page took 0.053023 seconds and 5 git commands to generate.