public static Range range()

in accord-core/src/main/java/accord/primitives/Range.java [149:213]


    public static Range range(RoutingKey start, RoutingKey end, boolean startInclusive, boolean endInclusive)
    {
        return new Range(start, end) {

            @Override
            public boolean startInclusive()
            {
                return startInclusive;
            }

            @Override
            public boolean endInclusive()
            {
                return endInclusive;
            }

            @Override
            public Range newRange(RoutingKey start, RoutingKey end)
            {
                throw new UnsupportedOperationException("subRange");
            }

            @Override
            public int compareTo(RoutableKey key)
            {
                if (startInclusive)
                {
                    if (key.compareTo(start()) < 0)
                        return 1;
                }
                else
                {
                    if (key.compareTo(start()) <= 0)
                        return 1;
                }
                if (endInclusive)
                {
                    if (key.compareTo(end()) > 0)
                        return -1;
                }
                else
                {
                    if (key.compareTo(end()) >= 0)
                        return -1;
                }
                return 0;
            }

            @Override
            public int compareStartTo(RoutableKey key)
            {
                int c = start().compareTo(key);
                if (c == 0 && !startInclusive) c = 1;
                return c;
            }

            @Override
            public int compareEndTo(RoutableKey key)
            {
                int c = end().compareTo(key);
                if (c == 0 && !endInclusive) c = -1;
                return c;
            }
        };
    }