datastore: remove Generic RangeConditions
authorLoïc Prieur-Drevon <loic.prieurdrevon@gmail.com>
Tue, 4 Apr 2017 01:33:21 +0000 (21:33 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 12 May 2017 19:03:42 +0000 (15:03 -0400)
Specific RangeConditions, backed by primitives and arrays are up
to 33% faster.

Change-Id: I7828d777f6a534cf1219669c374b261ac829f828
Signed-off-by: Loïc Prieur-Drevon <loic.prieurdrevon@gmail.com>
Reviewed-on: https://git.eclipse.org/r/94341
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/condition/ContinuousRangeConditionTest.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/condition/DiscreteRangeConditionTest.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/provisional/datastore/core/condition/RangeConditionTest.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/condition/ContinuousRangeCondition.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/condition/DiscreteRangeCondition.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/condition/RangeCondition.java [deleted file]

diff --git a/statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/condition/ContinuousRangeConditionTest.java b/statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/condition/ContinuousRangeConditionTest.java
deleted file mode 100644 (file)
index f05fc14..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 École Polytechnique de Montréal
- *
- * 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.internal.datastore.core.condition;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.RangeCondition;
-import org.junit.Test;
-
-/**
- * Test the continuous range condition with Integers.
- *
- * @author Loïc Prieur-Drevon
- */
-public class ContinuousRangeConditionTest {
-
-    private static final int LOW = 0;
-    private static final int HIGH = 10;
-    private static final ContinuousRangeCondition<Integer> CONDITION = new ContinuousRangeCondition<>(LOW, HIGH);
-
-    /**
-     * Ensure that we cannot build a condition with a bigger low than high bound.
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testConstructor() {
-        new ContinuousRangeCondition<>(HIGH, LOW);
-    }
-
-    /**
-     * Ensure that the minimum and maximum functions return the correct values.
-     */
-    @Test
-    public void testBounds() {
-        int low = CONDITION.min();
-        assertEquals(LOW, low);
-        int high = CONDITION.max();
-        assertEquals(HIGH, high);
-    }
-
-    /**
-     * Test that the right elements are contained in the condition.
-     */
-    @Test
-    public void testPredicate() {
-        assertFalse(CONDITION.test(-5));
-        assertTrue(CONDITION.test(LOW));
-        assertTrue(CONDITION.test(5));
-        assertTrue(CONDITION.test(HIGH));
-        assertFalse(CONDITION.test(15));
-    }
-
-    /**
-     * Test that the right intervals intersect the condition.
-     */
-    @Test
-    public void testIntersects() {
-        assertFalse(CONDITION.intersects(Integer.MIN_VALUE, LOW - 1));
-        assertTrue(CONDITION.intersects(-5, 5));
-        assertTrue(CONDITION.intersects(2, 8));
-        assertTrue(CONDITION.intersects(5, 15));
-        assertFalse(CONDITION.intersects(HIGH + 1, Integer.MAX_VALUE));
-    }
-
-    /**
-     * Test that the returned subcondition has the correct bounds.
-     */
-    @Test
-    public void testSubCondition() {
-        RangeCondition<Integer> sub = CONDITION.subCondition(-5, 8);
-        assertNotNull(sub);
-        assertEquals(ContinuousRangeCondition.class, sub.getClass());
-        int low = sub.min();
-        int high = sub.max();
-        assertEquals(LOW, low);
-        assertEquals(8, high);
-    }
-
-}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/condition/DiscreteRangeConditionTest.java b/statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/condition/DiscreteRangeConditionTest.java
deleted file mode 100644 (file)
index d26c353..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 École Polytechnique de Montréal
- *
- * 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.internal.datastore.core.condition;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.RangeCondition;
-import org.junit.Test;
-
-/**
- * Test the discrete range condition with Integers.
- *
- * @author Loïc Prieur-Drevon
- */
-public class DiscreteRangeConditionTest {
-
-    private static final int LOW = 0;
-    private static final int HIGH = 10;
-    private static final List<Integer> VALUES = Arrays.asList(LOW, HIGH / 2, HIGH);
-    private static final DiscreteRangeCondition<Integer> CONDITION = new DiscreteRangeCondition<>(VALUES);
-
-    /**
-     * Ensure that we cannot build a condition with an empty collection.
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testConstructor() {
-        new DiscreteRangeCondition<>(Collections.emptyList());
-    }
-
-    /**
-     * Ensure that the minimum and maximum functions return the correct values.
-     */
-    @Test
-    public void testBounds() {
-        assertEquals(LOW, (int) CONDITION.min());
-        assertEquals(HIGH, (int) CONDITION.max());
-    }
-
-    /**
-     * Test that the right elements are contained in the condition.
-     */
-    @Test
-    public void testPredicate() {
-        assertFalse(CONDITION.test(-5));
-        for (Integer v : VALUES) {
-            assertTrue(CONDITION.test(v));
-            assertFalse(CONDITION.test(v + 1));
-        }
-        assertFalse(CONDITION.test(15));
-    }
-
-    /**
-     * Test that modifying the list used to populate the condition does not
-     * affect the condition
-     */
-    @Test
-    public void testPredicateAndAdd() {
-        List<Integer> values = new ArrayList<>();
-        values.add(1);
-        values.add(5);
-        DiscreteRangeCondition<Integer> condition = new DiscreteRangeCondition<>(values);
-        assertFalse(condition.test(-5));
-        for (Integer v : values) {
-            assertTrue(condition.test(v));
-            assertFalse(condition.test(v + 1));
-        }
-        assertFalse(condition.test(15));
-        // Add the values to the initial set and make sure it is not part of the
-        // condition
-        values.add(15);
-        assertFalse(condition.test(15));
-    }
-
-    /**
-     * Test that the right intervals intersect the condition.
-     */
-    @Test
-    public void testIntersects() {
-        assertFalse(CONDITION.intersects(Integer.MIN_VALUE, LOW - 1));
-        assertTrue(CONDITION.intersects(0, 4));
-        assertFalse(CONDITION.intersects(1, 4));
-        assertTrue(CONDITION.intersects(2, 8));
-        assertFalse(CONDITION.intersects(6, 9));
-        assertTrue(CONDITION.intersects(5, 15));
-        assertFalse(CONDITION.intersects(HIGH + 1, Integer.MAX_VALUE));
-    }
-
-    /**
-     * Test that the returned subcondition has the correct bounds.
-     */
-    @Test
-    public void testSubCondition() {
-        RangeCondition<Integer> sub = CONDITION.subCondition(-5, 8);
-        assertNotNull(sub);
-        assertEquals(DiscreteRangeCondition.class, sub.getClass());
-        int low = sub.min();
-        int high = sub.max();
-        assertEquals(LOW, low);
-        assertEquals(HIGH / 2, high);
-
-        // For a range where no value is include, it should return null
-        sub = CONDITION.subCondition(LOW + 1, HIGH / 2 - 1);
-        assertNull(sub);
-    }
-
-}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/provisional/datastore/core/condition/RangeConditionTest.java b/statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/provisional/datastore/core/condition/RangeConditionTest.java
deleted file mode 100644 (file)
index d619032..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 École Polytechnique de Montréal
- *
- * 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.internal.provisional.datastore.core.condition;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.tracecompass.internal.datastore.core.condition.ContinuousRangeCondition;
-import org.eclipse.tracecompass.internal.datastore.core.condition.DiscreteRangeCondition;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Test the {@link RangeCondition} static methods
- *
- * @author Geneviève Bastien
- */
-public class RangeConditionTest {
-
-    /**
-     * Test the {@link RangeCondition#singleton(Comparable)} method
-     */
-    @Test
-    public void testSingleton() {
-        /* A test value */
-        Long value = 3L;
-        RangeCondition<Long> cnd = RangeCondition.singleton(3L);
-        /* Make sure the return value is a discrete range of the right value */
-        assertTrue(cnd instanceof DiscreteRangeCondition);
-        assertEquals(value, cnd.max());
-        assertEquals(value, cnd.min());
-    }
-
-    /**
-     * Test the
-     * {@link RangeCondition#forContinuousRange(Comparable, Comparable)} method
-     * for value with bound1 < bound2
-     */
-    @Test
-    public void testForContinuousRangeValid() {
-        Long min = 1L;
-        Long max = 10L;
-        RangeCondition<Long> cnd = RangeCondition.forContinuousRange(min, max);
-        assertTrue(cnd instanceof ContinuousRangeCondition);
-        assertEquals(min, cnd.min());
-        assertEquals(max, cnd.max());
-    }
-
-    /**
-     * Test the
-     * {@link RangeCondition#forContinuousRange(Comparable, Comparable)} method
-     * for value with bound1 > bound2
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testForContinuousRangeInvalid() {
-        Long min = 1L;
-        Long max = 10L;
-        RangeCondition.forContinuousRange(max, min);
-    }
-
-    /**
-     * Test the {@link RangeCondition#fromCollection(java.util.Collection)}
-     * method
-     */
-    @Test
-    public void testFromCollection() {
-        // Add a list of unsorted elements
-        ImmutableList<Long> elements = ImmutableList.of(1L, 4L, 2L, 10L, -3L);
-        RangeCondition<Long> cnd = RangeCondition.fromCollection(elements);
-        assertTrue(cnd instanceof DiscreteRangeCondition);
-        assertEquals(-3L, (long) cnd.min());
-        assertEquals(10L, (long) cnd.max());
-    }
-
-    /**
-     * Test the {@link RangeCondition#forDiscreteRange(long, long, long)} method
-     * for value with bound1 < bound2
-     */
-    @Test
-    public void testForDiscreteRangeValid() {
-
-        // Test with valid values and a step of 1: all values should be in the
-        // range
-        Long min = 1L;
-        Long max = 10L;
-        Long step = 1L;
-        RangeCondition<Long> cnd = RangeCondition.forDiscreteRange(min, max, step);
-        assertTrue(cnd instanceof DiscreteRangeCondition);
-        assertEquals(min, cnd.min());
-        assertEquals(max, cnd.max());
-        for (Long i = min; i <= max; i++) {
-            assertTrue(cnd.test(i));
-        }
-
-        // Test with a step of 0, it should take 1 as a default value
-        step = 0L;
-        cnd = RangeCondition.forDiscreteRange(min, max, step);
-        assertTrue(cnd instanceof DiscreteRangeCondition);
-        assertEquals(min, cnd.min());
-        assertEquals(max, cnd.max());
-        for (Long i = min; i <= max; i++) {
-            assertTrue(cnd.test(i));
-        }
-
-        // Test with a step of 2. Make sure that values have the right steps and
-        // the max element is part of the condition
-        step = 2L;
-        cnd = RangeCondition.forDiscreteRange(min, max, step);
-        assertTrue(cnd instanceof DiscreteRangeCondition);
-        assertEquals(min, cnd.min());
-        assertEquals(max, cnd.max());
-        for (Long i = min; i < max; i++) {
-            if ((i - min) % step == 0) {
-                assertTrue(cnd.test(i));
-            } else {
-                assertFalse(cnd.test(i));
-            }
-        }
-        assertTrue(cnd.test(max));
-    }
-
-    /**
-     * Test the {@link RangeCondition#forDiscreteRange(long, long, long)} method
-     * for value with bound1 > bound2
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testForDiscreteRangeInvalid() {
-        Long min = 1L;
-        Long max = 10L;
-        Long step = 1L;
-        RangeCondition.forDiscreteRange(max, min, step);
-    }
-
-    /**
-     * Test the {@link RangeCondition#forDiscreteRange(long, long, long)} method
-     * with a step < 0
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testForDiscreteRangeInvalidStep() {
-        Long min = 1L;
-        Long max = 10L;
-        Long step = -2L;
-        RangeCondition.forDiscreteRange(max, min, step);
-    }
-
-}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/condition/ContinuousRangeCondition.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/condition/ContinuousRangeCondition.java
deleted file mode 100644 (file)
index dcdd89e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 École Polytechnique de Montréal
- *
- * 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.internal.datastore.core.condition;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.RangeCondition;
-
-/**
- * Generic Range Condition. This condition will verify that a value are within a
- * range limited by a lower and upper bound.
- *
- * @author Loïc Prieur-Drevon
- * @param <E>
- *            Comparable type, for instance Long for timestamps
- */
-public class ContinuousRangeCondition<E extends Comparable<E>> implements RangeCondition<E> {
-
-    private final E fMin;
-    private final E fMax;
-
-    /**
-     * Build a continuous range condition from two bounds.
-     *
-     * @param low
-     *            The range's lower bound
-     * @param high
-     *            The range's higher bound
-     */
-    public ContinuousRangeCondition(@NonNull E low, @NonNull E high) {
-        if (low.compareTo(high) > 0) {
-            throw new IllegalArgumentException(low.toString() + " is greater than " + high.toString()); //$NON-NLS-1$
-        }
-        fMin = low;
-        fMax = high;
-    }
-
-    @Override
-    public E min() {
-        return fMin;
-    }
-
-    @Override
-    public E max() {
-        return fMax;
-    }
-
-    @Override
-    public boolean test(E element) {
-        return fMin.compareTo(element) <= 0 && element.compareTo(fMax) <= 0;
-    }
-
-    @Override
-    public boolean intersects(E low, E high) {
-        return fMin.compareTo(high) <= 0 && fMax.compareTo(low) >= 0;
-    }
-
-    private static <E extends Comparable<E>> E min(E n1, E n2) {
-        if (n1.compareTo(n2) <= 0) {
-            return n1;
-        }
-        return n2;
-    }
-
-    private static <E extends Comparable<E>> E max(E n1, E n2) {
-        if (n1.compareTo(n2) >= 0) {
-            return n1;
-        }
-        return n2;
-    }
-
-    @Override
-    public @NonNull RangeCondition<E> subCondition(E from, E to) {
-        return new ContinuousRangeCondition<>(max(from, fMin), min(fMax, to));
-    }
-
-    @Override
-    public String toString() {
-        return "Continuous condition: " + fMin.toString() + '-' + fMax.toString(); //$NON-NLS-1$
-    }
-
-}
\ No newline at end of file
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/condition/DiscreteRangeCondition.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/condition/DiscreteRangeCondition.java
deleted file mode 100644 (file)
index 184edfb..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 École Polytechnique de Montréal
- *
- * 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.internal.datastore.core.condition;
-
-import java.util.Collection;
-import java.util.NavigableSet;
-import java.util.TreeSet;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.RangeCondition;
-
-/**
- * Generic Set Condition. This condition will verify that a value is one of a
- * collection of values. It has a lower and upper bound, lower and upper bounds
- * of the collection, to limit the space of research, but within those bounds,
- * only the values in the collection are verified.
- *
- * @author Loïc Prieur-Drevon
- * @param <E>
- *            Comparable type, for instance Long for timestamps
- */
-public class DiscreteRangeCondition<E extends Comparable<E>> implements RangeCondition<E> {
-
-    /* the set will always have at least one element */
-    private final NavigableSet<@NonNull E> fSet;
-
-    /**
-     * Constructor for a NumCondition from a Collection of Integers
-     *
-     * @param c
-     *            Integers to include in Set Condition.
-     */
-    public DiscreteRangeCondition(Collection<E> c) {
-        if (c.isEmpty()) {
-            throw new IllegalArgumentException("DiscreteRangeCondition requires a non-empty collection"); //$NON-NLS-1$
-        }
-        fSet = new TreeSet<>(c);
-    }
-
-    @Override
-    public E min() {
-        return fSet.first();
-    }
-
-    @Override
-    public E max() {
-        return fSet.last();
-    }
-
-    @Override
-    public boolean test(E element) {
-        return fSet.contains(element);
-    }
-
-    /**
-     * Return true if the range [low, high] intersects at least one element from
-     * the Discrete Range.
-     *
-     * @param low
-     *            lower bound of the timerange
-     * @param high
-     *            upper bound of the timerange
-     */
-    @Override
-    public boolean intersects(E low, E high) {
-        @Nullable E floor = fSet.floor(high);
-        if (floor == null) {
-            /* There is no element smaller than high */
-            return false;
-        }
-        @Nullable E ceil = fSet.ceiling(low);
-        if (ceil == null) {
-            /* There is no element larger than low */
-            return false;
-        }
-        /* At least one element is between low and high */
-        return ceil.compareTo(floor) <= 0;
-    }
-
-    @Override
-    public @Nullable DiscreteRangeCondition<E> subCondition(E from, E to) {
-        if (from.compareTo(to) > 0) {
-            throw new IllegalArgumentException(from.toString() + " is greater than " + to.toString()); //$NON-NLS-1$
-        }
-        NavigableSet<@NonNull E> subSet = fSet.subSet(from, true, to, true);
-        if (subSet.isEmpty()) {
-            return null;
-        }
-        return new DiscreteRangeCondition<>(subSet);
-    }
-
-    @Override
-    public String toString() {
-        return "Discrete condition: " + fSet.toString(); //$NON-NLS-1$
-    }
-
-}
\ No newline at end of file
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/condition/RangeCondition.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/condition/RangeCondition.java
deleted file mode 100644 (file)
index b0ceea3..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 École Polytechnique de Montréal
- *
- * 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.internal.provisional.datastore.core.condition;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.function.Predicate;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.datastore.core.condition.ContinuousRangeCondition;
-import org.eclipse.tracecompass.internal.datastore.core.condition.DiscreteRangeCondition;
-
-/**
- * Describe conditions such as ranges or sets. These conditions are used for
- * example to abstract queries on history trees.
- *
- * New RangeCondition objects can be generated by using the
- * {@link #forContinuousRange} and {@link #fromCollection} factory methods.
- *
- * @author Loïc Prieur-Drevon
- *
- * @param <E>
- *            Comparable type that extends Number, typically an Integer or a
- *            Long
- * @noimplement Accessor interface
- */
-public interface RangeCondition<@NonNull E extends Comparable<E>> extends Predicate<E> {
-
-    /**
-     * Get the lower bound of this range
-     *
-     * @return the lowest acceptable value for this condition.
-     */
-    @NonNull E min();
-
-    /**
-     * Get the upper bound of this range
-     *
-     * @return the highest acceptable value for this condition.
-     */
-    @NonNull E max();
-
-    /**
-     * Test whether a value is within this specific range boundaries. If the
-     * range is continuous, it will return <code>true</code> if the value is
-     * between the lower and upper bounds. If the range is discrete, it will
-     * return <code>true</code> if the requested element is one of the elements
-     * in the discrete range.
-     *
-     * @param element
-     *            value that we want to test
-     * @return true if element is contained in this condition's set or range
-     */
-    @Override
-    boolean test(@NonNull E element);
-
-    /**
-     * Determine if the current range intersects a ranged bounded by the values
-     * in parameter
-     *
-     * @param low
-     *            interval's lower bound
-     * @param high
-     *            interval's upper bound
-     * @return true if this element intersects the range's condition or any of
-     *         the set's elements
-     */
-    boolean intersects(@NonNull E low, @NonNull E high);
-
-    /**
-     * Reduce the Condition to elements or the range within bounds from and to.
-     * <code>null</code> is returned if the resulting condition is empty.
-     *
-     * @param from
-     *            lower bound for the condition reduction.
-     * @param to
-     *            upper bound for the condition reduction.
-     * @return the reduced condition or <code>null</code> if the reduced
-     *         condition does not contain any element
-     */
-    @Nullable RangeCondition<E> subCondition(@NonNull E from, @NonNull E to);
-
-    /**
-     * Get a condition of a single element.
-     *
-     * @param elem The single element
-     * @return The corresponding range condition
-     */
-    static <E extends Comparable<E>> RangeCondition<E> singleton(E elem) {
-        return new DiscreteRangeCondition<>(Collections.singleton(elem));
-    }
-
-    /**
-     * Get a range condition representing a continuous time range.
-     *
-     * @param bound1
-     *            The first bound
-     * @param bound2
-     *            The second bound. It's fine for bound2 to be > or < than
-     *            bound1.
-     * @return The corresponding range condition
-     */
-    static <E extends Comparable<E>> RangeCondition<E> forContinuousRange(
-            E bound1, E bound2) {
-        return new ContinuousRangeCondition<>(bound1, bound2);
-    }
-
-    /**
-     * Get a range condition representing distinct elements within a range.
-     *
-     * @param collection
-     *            A collection of individual elements
-     * @return The corresponding range condition
-     */
-    static <E extends Comparable<E>> RangeCondition<E> fromCollection(
-            Collection<E> collection) {
-        return new DiscreteRangeCondition<>(collection);
-    }
-
-    /**
-     * Utility method to generate a range condition of discrete elements, by
-     * providing a min, a max, and a "step" between each elements. Note that
-     * "max" will be included in the condition.
-     *
-     * For example, specifying (min=1, max=10, step=2) will return a condition
-     * representing [1, 3, 5, 7, 9, 10].
-     *
-     * @param min
-     *            The minimum value
-     * @param max
-     *            The maximum value. Should be greater than or equal to min
-     * @param step
-     *            The step between each element
-     * @return The corresponding range condition
-     */
-    static RangeCondition<Long> forDiscreteRange(long min, long max, long step) {
-        if (max < min || step < 0) {
-            throw new IllegalArgumentException("Invalid range: max should be < min and step >= 0 (max: " + max + ", min:" + min + ", step: " + step + ')');  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-        }
-        /*
-         * If resolution is 0, adjust increment to return consecutive number
-         */
-        long increment = Math.max(step, 1L);
-        Set<Long> times = new TreeSet<>();
-        for (long t = min; t < max; t += increment) {
-            times.add(t);
-        }
-        times.add(max);
-
-        return fromCollection(times);
-    }
-}
-
This page took 0.031721 seconds and 5 git commands to generate.