Throwable Optional

Java utility class that enables the possibility to use the Optional with functions that can throw exceptions

License

License

GroupId

GroupId

xyz.brandonfl
ArtifactId

ArtifactId

throwable-optional
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Throwable Optional
Java utility class that enables the possibility to use the Optional with functions that can throw exceptions
Project URL

Project URL

https://github.com/brandonfl/throwable-optional
Source Code Management

Source Code Management

http://github.com/brandonfl/throwable-optional/tree/master

Download throwable-optional

How to add to project

<!-- https://jarcasting.com/artifacts/xyz.brandonfl/throwable-optional/ -->
<dependency>
    <groupId>xyz.brandonfl</groupId>
    <artifactId>throwable-optional</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/xyz.brandonfl/throwable-optional/
implementation 'xyz.brandonfl:throwable-optional:1.0.2'
// https://jarcasting.com/artifacts/xyz.brandonfl/throwable-optional/
implementation ("xyz.brandonfl:throwable-optional:1.0.2")
'xyz.brandonfl:throwable-optional:jar:1.0.2'
<dependency org="xyz.brandonfl" name="throwable-optional" rev="1.0.2">
  <artifact name="throwable-optional" type="jar" />
</dependency>
@Grapes(
@Grab(group='xyz.brandonfl', module='throwable-optional', version='1.0.2')
)
libraryDependencies += "xyz.brandonfl" % "throwable-optional" % "1.0.2"
[xyz.brandonfl/throwable-optional "1.0.2"]

Dependencies

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.1.0
junit : junit jar RELEASE

Project Modules

There are no modules declared in this project.


Throwable Optional

Java utility class that enables the possibility to use the Optional with functions that can throw exceptions

release maven-central Java CI Sonar Publish Maven package Sonar gate licence

How to useVariablesLicence

How to use

Installation

<dependency>
  <groupId>xyz.brandonfl</groupId>
  <artifactId>throwable-optional</artifactId>
  <version>VERSION</version>
</dependency>
mvn install

More informations : https://github.com/brandonfl/throwable-optional/packages/

Examples

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 licence

Versions

Version
1.0.2
1.0.1
1.0.0
0.0.1