Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brandonfl/throwable-optional
Java utility class that enables the possibility to use the Optional with functions that can throw exceptions
https://github.com/brandonfl/throwable-optional
java java-utility util utility utility-library utils
Last synced: 26 days ago
JSON representation
Java utility class that enables the possibility to use the Optional with functions that can throw exceptions
- Host: GitHub
- URL: https://github.com/brandonfl/throwable-optional
- Owner: brandonfl
- License: mit
- Created: 2020-11-21T11:30:50.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-18T18:09:35.000Z (over 2 years ago)
- Last Synced: 2023-07-27T17:13:32.194Z (over 1 year ago)
- Topics: java, java-utility, util, utility, utility-library, utils
- Language: Java
- Homepage: https://throwable-optional.docs.brandonfl.dev
- Size: 306 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#
Throwable Optional
Java utility class that enables the possibility to use the Optional with functions that can throw exceptions
How to use •
Variables •
Licence## How to use
#### Installation
```xmlxyz.brandonfl
throwable-optional
VERSION```
```sh
mvn install
```
More informations : https://github.com/brandonfl/throwable-optional/packages/#### Examples
```java
public static void main(String[] args){
long valueWithTest = ThrowableOptional
.of(() -> Long.parseLong("test"))
.orElse(0L);long valueWith1 = ThrowableOptional
.of(() -> Long.parseLong("1"))
.orElse(0L);long valueWithFunction = ThrowableOptional
.of(Long::parseLong, "1")
.orElse(0L);System.out.println(valueWithTest);
System.out.println(valueWith1);
System.out.println(valueWithFunction);
}
```That will return without exceptions :
```
0
1
1
```## Licence
Project under [MIT](https://github.com/brandonfl/throwable-optional/blob/master/LICENSE) licence