Skip to content

feat: add parseOptional method (try-parse pattern) #56

Description

@neewrobert

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions