/** Returns a one-point interval. * * <P>You cannot obtain an empty interval with this factory method. Use {@link Intervals#EMPTY_INTERVAL} instead. * * @param point a point. * @return a one-point interval */ public static LongInterval valueOf(final long point) { if (point >= 0 && point < MAX_SINGLE_POINT) return POINT_INTERVAL[(int)point]; return new LongInterval(point, point); }
/** Returns an interval with given extremes. * * <P>You cannot obtain an empty interval with this factory method. Use {@link Intervals#EMPTY_INTERVAL} instead. * * @param left the left extreme. * @param right the right extreme (which must be greater than * or equal to the left extreme). * @return an interval with the given extremes. */ public static LongInterval valueOf(final long left, final long right) { if (left > right) throw new IllegalArgumentException("The left extreme (" + left + ") is greater than the right extreme (" + right + ")"); if (left == right) return valueOf(left); return new LongInterval(left, right); }