Summary
Currently, RangeParser.parse() throws RangeParseException on invalid input. A common use case is to attempt parsing without exception handling.
Proposal
Add a method that returns Optional<Range<T>> instead of throwing:
Optional<Range<Integer>> range = parser.parseOptional("[1..10]", Integer.class);
This follows the try-parse pattern common in Java libraries and is useful for:
- Validating user input without try/catch
- Stream processing where invalid ranges should be filtered
- Optional configuration values
Summary
Currently,
RangeParser.parse()throwsRangeParseExceptionon invalid input. A common use case is to attempt parsing without exception handling.Proposal
Add a method that returns
Optional<Range<T>>instead of throwing:This follows the try-parse pattern common in Java libraries and is useful for: