segStore: Add a close method to ISegmentStore
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.segmentstore.core / src / org / eclipse / tracecompass / segmentstore / core / ISegment.java
CommitLineData
26a6a7eb
AM
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
13package org.eclipse.tracecompass.segmentstore.core;
14
15import java.io.Serializable;
16
f1c52947
JCK
17import org.eclipse.jdt.annotation.NonNull;
18
26a6a7eb
AM
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 */
f1c52947 25public interface ISegment extends Serializable, Comparable<@NonNull ISegment> {
26a6a7eb
AM
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
f1c52947
JCK
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
26a6a7eb 48 /**
524d1e78 49 * The length/duration of the segment.
26a6a7eb
AM
50 *
51 * @return The duration
52 */
524d1e78
AM
53 default long getLength() {
54 return getEnd() - getStart();
55 }
26a6a7eb 56}
This page took 0.034619 seconds and 5 git commands to generate.