ss: Provide a basic implementation of ISegment
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 29 Jul 2015 17:23:34 +0000 (13:23 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 6 Aug 2015 19:18:02 +0000 (15:18 -0400)
Change-Id: Ic66504a2b136ac00c21a37ac526b09db4dba32db
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/52816
Reviewed-by: France Lapointe Nguyen <francelap@gmail.com>
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java [new file with mode: 0644]

diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java
new file mode 100644 (file)
index 0000000..8abd688
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.segmentstore.core;
+
+/**
+ * Basic implementation of {@link ISegment}.
+ *
+ * @author Alexandre Montplaisir
+ */
+public class BasicSegment implements ISegment {
+
+    private static final long serialVersionUID = -3257452887960883177L;
+
+    private final long fStart;
+    private final long fEnd;
+
+    /**
+     * Create a new segment.
+     *
+     * The end position should be equal to or greater than the start position.
+     *
+     * @param start
+     *            Start position of the segment
+     * @param end
+     *            End position of the segment
+     */
+    public BasicSegment(long start, long end) {
+        if (end < start) {
+            throw new IllegalArgumentException();
+        }
+        fStart = start;
+        fEnd = end;
+    }
+
+    @Override
+    public long getStart() {
+        return fStart;
+    }
+
+    @Override
+    public long getEnd() {
+        return fEnd;
+    }
+
+    @Override
+    public long getLength() {
+        return (fEnd - fStart);
+    }
+
+    @Override
+    public String toString() {
+        return new String('[' + String.valueOf(fStart) + ", " + String.valueOf(fEnd) + ']'); //$NON-NLS-1$
+    }
+
+}
This page took 0.025162 seconds and 5 git commands to generate.