![](/style/images/good.png)
![](/style/images/bad.png)
DeclarativeX — A Composable approach to exception & conditions in Java
source link: https://dev.to/muthuishere/declarativex-a-composable-approach-to-exception-conditions-in-java-1lf
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
![Cover image for DeclarativeX — A Composable approach to exception & conditions in Java](https://res.cloudinary.com/practicaldev/image/fetch/s--ae8B3N0f--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7z2b0nd1iw90no7t2k97.png)
DeclarativeX — A Composable approach to exception & conditions in Java
Sep 3
・1 min read
The idea of utilizing functional programming is to enable declarative programming along with supporting concurrency & state issues.
Most of the items are already better with Java 8 in terms of declarative programming, with the help of Optional Monad, Streams API.
I could sense a need, especially in exception handling and conditions. We might need a composable api to effectively handle exceptions and multi conditions.
The Declarativex library attempts to solve the issue through some functional and fluent interface way.
Chaining Exceptions
If all your functions has the same parameter within chaining, You can use this alternative
Catching Exceptions based on Type and Performing appropriate actions
Logging / peeking
Composing Conditions
Usage
Add Dependency
<dependency>
<groupId>io.github.muthuishere</groupId>
<artifactId>declarativex</artifactId>
</dependency>
Import with
import declarativex.Try;
import declarativex.Filter;
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK