private static Bound<?> createBound(Number number, boolean inclusive) { if (number instanceof Long) { return inclusive ? Bound.inclusive((Long) number) : Bound.exclusive((Long) number); } if (number instanceof Double) { return inclusive ? Bound.inclusive((Double) number) : Bound.exclusive((Double) number); } if (number instanceof Float) { return inclusive ? Bound.inclusive((Float) number) : Bound.exclusive((Float) number); } if (number instanceof Integer) { return inclusive ? Bound.inclusive((Integer) number) : Bound.exclusive((Integer) number); } if (number instanceof BigDecimal) { return inclusive ? Bound.inclusive((BigDecimal) number) : Bound.exclusive((BigDecimal) number); } throw new IllegalArgumentException("Unsupported numeric value."); }
private static Bound<?> createBound(Number number, boolean inclusive) { if (number instanceof Long) { return inclusive ? Bound.inclusive((Long) number) : Bound.exclusive((Long) number); } if (number instanceof Double) { return inclusive ? Bound.inclusive((Double) number) : Bound.exclusive((Double) number); } if (number instanceof Float) { return inclusive ? Bound.inclusive((Float) number) : Bound.exclusive((Float) number); } if (number instanceof Integer) { return inclusive ? Bound.inclusive((Integer) number) : Bound.exclusive((Integer) number); } if (number instanceof BigDecimal) { return inclusive ? Bound.inclusive((BigDecimal) number) : Bound.exclusive((BigDecimal) number); } throw new IllegalArgumentException("Unsupported numeric value."); }
private OrderLine getRequiredOrderLineByIndex(int index) { Range<Integer> allowedIndexRange = Range.from(Bound.inclusive(0))// .to(Bound.exclusive(orderLines.size())); Assert.isTrue(allowedIndexRange.contains(index), String.format("Invalid order line index %s. Required: %s!", index, allowedIndexRange)); return this.orderLines.get(index); }
/** * Creates a new {@link Range} with the given lower and upper bound as well as the given inclusive/exclusive * semantics. * * @param lowerBound can be {@literal null}. * @param upperBound can be {@literal null}. * @param lowerInclusive * @param upperInclusive * @deprecated since 2.0. Use {@link Range#of(Bound, Bound)} and {@link Bound} factory methods: * {@link Bound#inclusive(Comparable)}, {@link Bound#exclusive(Comparable)}/{@link Bound#unbounded()}. */ @Deprecated public Range(T lowerBound, T upperBound, boolean lowerInclusive, boolean upperInclusive) { this.lowerBound = lowerBound == null ? Bound.unbounded() : lowerInclusive ? Bound.inclusive(lowerBound) : Bound.exclusive(lowerBound); this.upperBound = upperBound == null ? Bound.unbounded() : upperInclusive ? Bound.inclusive(upperBound) : Bound.exclusive(upperBound); }
/** * Creates a boundary excluding {@code value}. * * @param value must not be {@literal null}. * @return */ public static Bound<Integer> exclusive(int value) { return exclusive((Integer) value); }
/** * Creates a boundary excluding {@code value}. * * @param value must not be {@literal null}. * @return */ public static Bound<Float> exclusive(float value) { return exclusive((Float) value); }
/** * Creates a boundary excluding {@code value}. * * @param value must not be {@literal null}. * @return */ public static Bound<Long> exclusive(long value) { return exclusive((Long) value); }
/** * Creates a boundary excluding {@code value}. * * @param value must not be {@literal null}. * @return */ public static Bound<Double> exclusive(double value) { return exclusive((Double) value); }