ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / TmfLostEvent.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
11 * Alexandre Montplaisir - Made immutable
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.core.event;
15
16 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
17 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
18 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
19
20 /**
21 * A basic implementation of ITmfLostEvent.
22 *
23 * @author Francois Chouinard
24 * @version 1.0
25 * @since 1.2
26 */
27 public class TmfLostEvent extends TmfEvent implements ITmfLostEvent {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
33 private final TmfTimeRange fTimeRange;
34 private final long fNbLostEvents;
35
36 // ------------------------------------------------------------------------
37 // Constructors
38 // ------------------------------------------------------------------------
39
40 /**
41 * Full constructor
42 *
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
59 * @since 2.0
60 */
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) {
69 super(trace, rank, timestamp, source, type, null, reference);
70 fTimeRange = timeRange;
71 fNbLostEvents = nbLostEvents;
72 }
73
74 // ------------------------------------------------------------------------
75 // ITmfLostEvent
76 // ------------------------------------------------------------------------
77
78 /**
79 * @since 2.0
80 */
81 @Override
82 public TmfTimeRange getTimeRange() {
83 return fTimeRange;
84 }
85
86 @Override
87 public long getNbLostEvents() {
88 return fNbLostEvents;
89 }
90
91 // ------------------------------------------------------------------------
92 // Object
93 // ------------------------------------------------------------------------
94
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
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
129 @Override
130 @SuppressWarnings("nls")
131 public String toString() {
132 return getClass().getSimpleName() + " [Event=" + super.toString() +
133 ", fTimeRange=" + fTimeRange + ", fNbLostEvents=" + fNbLostEvents + "]";
134 }
135
136 }
This page took 0.052287 seconds and 5 git commands to generate.