Fix some null warnings
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / statesystem / core / interval / TmfStateInterval.java
CommitLineData
a52fde77 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2012, 2014 Ericsson
a52fde77
AM
3 * Copyright (c) 2010, 2011 École Polytechnique de Montréal
4 * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
5df842b3 5 *
a52fde77
AM
6 * All rights reserved. This program and the accompanying materials are
7 * made available under the terms of the Eclipse Public License v1.0 which
8 * accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
5df842b3 10 *
a52fde77
AM
11 *******************************************************************************/
12
e894a508 13package org.eclipse.tracecompass.statesystem.core.interval;
a52fde77 14
aa353506 15import org.eclipse.jdt.annotation.NonNull;
e894a508 16import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
a52fde77 17
ab400cf1
AM
18import com.google.common.base.Objects;
19
a52fde77
AM
20/**
21 * The StateInterval represents the "state" a particular attribute was in, at a
22 * given time. It is the main object being returned from queries to the state
23 * system.
5df842b3 24 *
2cb26548 25 * @author Alexandre Montplaisir
a52fde77
AM
26 */
27public final class TmfStateInterval implements ITmfStateInterval {
28
29 private final long start;
30 private final long end;
31 private final int attribute;
aa353506 32 private final @NonNull ITmfStateValue sv;
a52fde77
AM
33
34 /**
35 * Construct an interval from its given parameters
5df842b3 36 *
a52fde77 37 * @param start
5df842b3 38 * Start time
a52fde77 39 * @param end
5df842b3 40 * End time
a52fde77 41 * @param attribute
5df842b3 42 * Attribute linked to this interval
a52fde77 43 * @param sv
5df842b3 44 * State value this interval will contain
a52fde77
AM
45 */
46 public TmfStateInterval(long start, long end, int attribute,
aa353506 47 @NonNull ITmfStateValue sv) {
a52fde77
AM
48 this.start = start;
49 this.end = end;
50 this.attribute = attribute;
51 this.sv = sv;
52 }
53
54 @Override
55 public long getStartTime() {
56 return start;
57 }
58
59 @Override
60 public long getEndTime() {
61 return end;
62 }
63
64 @Override
65 public int getAttribute() {
66 return attribute;
67 }
68
69 @Override
70 public ITmfStateValue getStateValue() {
71 return sv;
72 }
73
74 @Override
75 public boolean intersects(long timestamp) {
76 if (start <= timestamp) {
77 if (end >= timestamp) {
78 return true;
79 }
80 }
81 return false;
82 }
83
84 @Override
85 public String toString() {
86 /* Only used for debugging */
ab400cf1
AM
87 return Objects.toStringHelper(this)
88 .add("start", start) //$NON-NLS-1$
89 .add("end", end) //$NON-NLS-1$
90 .add("key", attribute) //$NON-NLS-1$
91 .add("value", sv.toString()) //$NON-NLS-1$
92 .toString();
a52fde77
AM
93 }
94
95}
This page took 0.074901 seconds and 5 git commands to generate.