https://github.com/robtimus/try-parse
Provides functionality to parse to Optional and its primitive versions
https://github.com/robtimus/try-parse
java optional optionals parse
Last synced: 2 months ago
JSON representation
Provides functionality to parse to Optional and its primitive versions
- Host: GitHub
- URL: https://github.com/robtimus/try-parse
- Owner: robtimus
- License: apache-2.0
- Created: 2019-04-28T11:34:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-20T12:51:54.000Z (almost 2 years ago)
- Last Synced: 2025-01-18T01:45:20.498Z (12 months ago)
- Topics: java, optional, optionals, parse
- Language: Java
- Homepage: https://robtimus.github.io/try-parse/
- Size: 429 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# try-parse
[](https://search.maven.org/artifact/com.github.robtimus/try-parse)
[](https://github.com/robtimus/try-parse/actions/workflows/build.yml)
[](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Atry-parse)
[](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Atry-parse)
[](https://snyk.io/test/github/robtimus/try-parse)
Provides functionality to parse to [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html) and its primitive versions.
Currently there are five sets of methods:
* `TryParse.tryParseInt`: a copy of `Integer.parseInt` to parse to [OptionalInt](https://docs.oracle.com/javase/8/docs/api/java/util/OptionalInt.html) instead of throwing exceptions.
* `TryParse.tryParseUnsignedInt`: a copy of `Integer.parseUnsignedInt` to parse to [OptionalInt](https://docs.oracle.com/javase/8/docs/api/java/util/OptionalInt.html) instead of throwing exceptions.
* `TryParse.tryParseLong`: a copy of `Long.parseLong` to parse to [OptionalLong](https://docs.oracle.com/javase/8/docs/api/java/util/OptionalLong.html) instead of throwing exceptions.
* `TryParse.tryParseUnsignedLong`: a copy of `Long.parseUnsignedLong` to parse to [OptionalLong](https://docs.oracle.com/javase/8/docs/api/java/util/OptionalLong.html) instead of throwing exceptions.
* `TryParse.tryParseBoolean`: a copy of `Boolean.parseBoolean` to parse to [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html) instead of returning `false`.
In addition, there are several methods that delegate to an existing method, catching expected exceptions. These are not as fast as the above five sets, but can still be useful.