Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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


release
maven-central
Java CI
CodeQL
Sonar gate
licence


How to use
Variables
Licence

## How to use
#### Installation
```xml

xyz.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