try-parse

Provides functionality to parse to Optional and its primitive versions.

Currently there are five sets of methods:

  • TryParse.tryParseInt: a copy of Integer.parseInt to parse to OptionalInt instead of throwing exceptions.
  • TryParse.tryParseUnsignedInt: a copy of Integer.parseUnsignedInt to parse to OptionalInt instead of throwing exceptions.
  • TryParse.tryParseLong: a copy of Long.parseLong to parse to OptionalLong instead of throwing exceptions.
  • TryParse.tryParseUnsignedLong: a copy of Long.parseUnsignedLong to parse to OptionalLong instead of throwing exceptions.
  • TryParse.tryParseBoolean: a copy of Boolean.parseBoolean to parse to Optional 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.