Commit | Line | Data |
---|---|---|
5a90de55 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 | ||
10 | package org.eclipse.tracecompass.segmentstore.core; | |
11 | ||
12 | /** | |
13 | * Basic implementation of {@link ISegment}. | |
14 | * | |
15 | * @author Alexandre Montplaisir | |
16 | */ | |
17 | public class BasicSegment implements ISegment { | |
18 | ||
19 | private static final long serialVersionUID = -3257452887960883177L; | |
20 | ||
21 | private final long fStart; | |
22 | private final long fEnd; | |
23 | ||
24 | /** | |
25 | * Create a new segment. | |
26 | * | |
27 | * The end position should be equal to or greater than the start position. | |
28 | * | |
29 | * @param start | |
30 | * Start position of the segment | |
31 | * @param end | |
32 | * End position of the segment | |
33 | */ | |
34 | public BasicSegment(long start, long end) { | |
35 | if (end < start) { | |
36 | throw new IllegalArgumentException(); | |
37 | } | |
38 | fStart = start; | |
39 | fEnd = end; | |
40 | } | |
41 | ||
42 | @Override | |
43 | public long getStart() { | |
44 | return fStart; | |
45 | } | |
46 | ||
47 | @Override | |
48 | public long getEnd() { | |
49 | return fEnd; | |
50 | } | |
51 | ||
5a90de55 AM |
52 | @Override |
53 | public String toString() { | |
54 | return new String('[' + String.valueOf(fStart) + ", " + String.valueOf(fEnd) + ']'); //$NON-NLS-1$ | |
55 | } | |
5a90de55 | 56 | } |