/** * Return the lower bound index from {@link Range} or {@literal 0} (zero) if the lower range is not bounded to point * to the first element. To be used with index-based commands such as {@code LRANGE}, {@code GETRANGE}. * * @param range * @return the lower index bound value or {@literal 0} for the first element if not bounded. * @since 2.0.9 */ static long getLowerBoundIndex(org.springframework.data.domain.Range<Long> range) { return getLowerBound(range).orElse(INDEXED_RANGE_START); }
/** * Return the lower bound index from {@link Range} or {@literal 0} (zero) if the lower range is not bounded to point * to the first element. To be used with index-based commands such as {@code LRANGE}, {@code GETRANGE}. * * @param range * @return the lower index bound value or {@literal 0} for the first element if not bounded. * @since 2.0.9 */ static long getLowerBoundIndex(org.springframework.data.domain.Range<Long> range) { return getLowerBound(range).orElse(INDEXED_RANGE_START); }
/** * Return the lower bound index from {@link Range} or {@literal 0} (zero) if the lower range is not bounded to point * to the first element. To be used with index-based commands such as {@code LRANGE}, {@code GETRANGE}. * * @param range * @return the lower index bound value or {@literal 0} for the first element if not bounded. * @since 2.0.9 */ static long getLowerBoundIndex(org.springframework.data.domain.Range<Long> range) { return getLowerBound(range).orElse(INDEXED_RANGE_START); }
private static Converter<org.springframework.data.domain.Range<?>, Boundary<?>> rangeToBoundArgumentConverter( Boolean upper) { return (source) -> { Boolean inclusive = upper ? source.getUpperBound().isInclusive() : source.getLowerBound().isInclusive(); Object value = upper ? LettuceConverters.getUpperBound(source).orElse(null) : LettuceConverters.getLowerBound(source).orElse(null); if (value == null) { return Boundary.unbounded(); } if (value instanceof Number) { return inclusive ? Boundary.including((Number) value) : Boundary.excluding((Number) value); } if (value instanceof String) { StringCodec stringCodec = new StringCodec(LettuceCharsets.UTF8); if (!StringUtils.hasText((String) value) || ObjectUtils.nullSafeEquals(value, "+") || ObjectUtils.nullSafeEquals(value, "-")) { return Boundary.unbounded(); } return inclusive ? Boundary.including(stringCodec.encodeValue((String) value)) : Boundary.excluding(stringCodec.encodeValue((String) value)); } return inclusive ? Boundary.including((ByteBuffer) value) : Boundary.excluding((ByteBuffer) value); }; } }
private static Converter<org.springframework.data.domain.Range<?>, Boundary<?>> rangeToBoundArgumentConverter( Boolean upper) { return (source) -> { Boolean inclusive = upper ? source.getUpperBound().isInclusive() : source.getLowerBound().isInclusive(); Object value = upper ? LettuceConverters.getUpperBound(source).orElse(null) : LettuceConverters.getLowerBound(source).orElse(null); if (value == null) { return Boundary.unbounded(); } if (value instanceof Number) { return inclusive ? Boundary.including((Number) value) : Boundary.excluding((Number) value); } if (value instanceof String) { StringCodec stringCodec = new StringCodec(LettuceCharsets.UTF8); if (!StringUtils.hasText((String) value) || ObjectUtils.nullSafeEquals(value, "+") || ObjectUtils.nullSafeEquals(value, "-")) { return Boundary.unbounded(); } return inclusive ? Boundary.including(stringCodec.encodeValue((String) value)) : Boundary.excluding(stringCodec.encodeValue((String) value)); } return inclusive ? Boundary.including((ByteBuffer) value) : Boundary.excluding((ByteBuffer) value); }; } }