ss: Avoid concatenating nonliterals in TmfStateInterval#toString()
[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
e894a508 15import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
a52fde77 16
ab400cf1
AM
17import com.google.common.base.Objects;
18
a52fde77
AM
19/**
20 * The StateInterval represents the "state" a particular attribute was in, at a
21 * given time. It is the main object being returned from queries to the state
22 * system.
5df842b3 23 *
2cb26548 24 * @author Alexandre Montplaisir
a52fde77
AM
25 */
26public final class TmfStateInterval implements ITmfStateInterval {
27
28 private final long start;
29 private final long end;
30 private final int attribute;
31 private final ITmfStateValue sv;
32
33 /**
34 * Construct an interval from its given parameters
5df842b3 35 *
a52fde77 36 * @param start
5df842b3 37 * Start time
a52fde77 38 * @param end
5df842b3 39 * End time
a52fde77 40 * @param attribute
5df842b3 41 * Attribute linked to this interval
a52fde77 42 * @param sv
5df842b3 43 * State value this interval will contain
a52fde77
AM
44 */
45 public TmfStateInterval(long start, long end, int attribute,
46 ITmfStateValue sv) {
47 this.start = start;
48 this.end = end;
49 this.attribute = attribute;
50 this.sv = sv;
51 }
52
53 @Override
54 public long getStartTime() {
55 return start;
56 }
57
58 @Override
59 public long getEndTime() {
60 return end;
61 }
62
63 @Override
64 public int getAttribute() {
65 return attribute;
66 }
67
68 @Override
69 public ITmfStateValue getStateValue() {
70 return sv;
71 }
72
73 @Override
74 public boolean intersects(long timestamp) {
75 if (start <= timestamp) {
76 if (end >= timestamp) {
77 return true;
78 }
79 }
80 return false;
81 }
82
83 @Override
84 public String toString() {
85 /* Only used for debugging */
ab400cf1
AM
86 return Objects.toStringHelper(this)
87 .add("start", start) //$NON-NLS-1$
88 .add("end", end) //$NON-NLS-1$
89 .add("key", attribute) //$NON-NLS-1$
90 .add("value", sv.toString()) //$NON-NLS-1$
91 .toString();
a52fde77
AM
92 }
93
94}
This page took 0.072035 seconds and 5 git commands to generate.