Add option to have compact of exaustive int/long suggestions
This commit is contained in:
parent
89db9b7a64
commit
3e7b5c6820
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import fr.pandacube.lib.core.util.ListUtil;
|
||||
@ -106,8 +107,8 @@ public interface SuggestionsSupplier<S> {
|
||||
* @param max
|
||||
* @return
|
||||
*/
|
||||
public static <S> SuggestionsSupplier<S> fromIntRange(int min, int max) {
|
||||
return fromLongRange(min, max);
|
||||
public static <S> SuggestionsSupplier<S> fromIntRange(int min, int max, boolean compact) {
|
||||
return fromLongRange(min, max, compact);
|
||||
}
|
||||
|
||||
|
||||
@ -121,10 +122,11 @@ public interface SuggestionsSupplier<S> {
|
||||
* @param max
|
||||
* @return
|
||||
*/
|
||||
public static <S> SuggestionsSupplier<S> fromLongRange(long min, long max) {
|
||||
public static <S> SuggestionsSupplier<S> fromLongRange(long min, long max, boolean compact) {
|
||||
if (max < min) {
|
||||
throw new IllegalArgumentException("min should be less or equals than max");
|
||||
}
|
||||
if (compact) {
|
||||
return (s, ti, token, a) -> {
|
||||
try {
|
||||
List<Long> proposedValues = new ArrayList<>();
|
||||
@ -183,6 +185,10 @@ public interface SuggestionsSupplier<S> {
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
return (s, ti, token, a) -> collectFilteredStream(LongStream.rangeClosed(min, max).mapToObj(Long::toString), token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user