Is there a way to filter out all values that are bigger than the max value that can be stored in a Long using Stream API?
The current situation is that you can search in the frontend with a simple search bar after some customers by using their ID.
For example: 123456789, 10987654321. If you put a "separator" between these two IDs, everything works. But if you forget the "separator" my code is trying to parse 12345678910987654321 into a Long and I guess there is the problem.
That causes a NumberFormatException after trying to search. Is there a way to filter these numbers out that can't be parsed into a Long because they are too big?
String hyphen = "-";
String[] customerIds = bulkCustomerIdProperty.getValue()
.replaceAll("[^0-9]", hyphen)
.split(hyphen);
...
customerFilter.setCustomerIds(Arrays.asList(customerIds).stream()
.filter(n -> !n.isEmpty())
.map(n -> Long.valueOf(n)) // convert to Long
.collect(Collectors.toSet()));