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