eff096573ab314292ec92bfd0ffd3e5259d6285c
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.segmentstore.core / src / org / eclipse / tracecompass / segmentstore / core / ISegment.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.segmentstore.core;
14
15 import java.io.Serializable;
16
17 import org.eclipse.jdt.annotation.NonNull;
18
19 /**
20 * Generic interface for any segment (like a time range) that can be used in the
21 * segment store.
22 *
23 * @author Alexandre Montplaisir
24 */
25 public interface ISegment extends Serializable, Comparable<@NonNull ISegment> {
26
27 /**
28 * The start position/time of the segment.
29 *
30 * @return The start position
31 */
32 long getStart();
33
34 /**
35 * The end position/time of the segment
36 *
37 * @return The end position
38 */
39 long getEnd();
40
41 @Override
42 default int compareTo(@NonNull ISegment arg0) {
43 return SegmentComparators.INTERVAL_START_COMPARATOR
44 .thenComparing(SegmentComparators.INTERVAL_END_COMPARATOR)
45 .compare(this, arg0);
46 }
47
48 /**
49 * The length/duration of the segment.
50 *
51 * @return The duration
52 */
53 default long getLength() {
54 return getEnd() - getStart();
55 }
56 }
This page took 0.034275 seconds and 5 git commands to generate.