Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romanqed/jconv
Flexible and lightweight pipeline implementation for java 11+ in style ASP.NET middleware.
https://github.com/romanqed/jconv
action conveyer conveyor java java-11 java-17 java11 java17 lightweight middleware pipeline task
Last synced: 24 days ago
JSON representation
Flexible and lightweight pipeline implementation for java 11+ in style ASP.NET middleware.
- Host: GitHub
- URL: https://github.com/romanqed/jconv
- Owner: RomanQed
- License: apache-2.0
- Created: 2024-01-16T22:15:02.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-10-05T21:24:43.000Z (about 1 month ago)
- Last Synced: 2024-10-13T04:03:49.573Z (24 days ago)
- Topics: action, conveyer, conveyor, java, java-11, java-17, java11, java17, lightweight, middleware, pipeline, task
- Language: Java
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jconv [![maven-central](https://img.shields.io/maven-central/v/com.github.romanqed/jconv?color=blue)](https://repo1.maven.org/maven2/com/github/romanqed/jconv/)
Flexible and lightweight pipeline implementation for java 11+ in style ASP.NET middleware.
## Getting Started
To install it, you will need:
* Java 11+
* Maven/Gradle### Features
## Installing
### Gradle dependency
```Groovy
dependencies {
implementation group: 'com.github.romanqed', name: 'jconv', version: 'LATEST'
}
```### Maven dependency
```
com.github.romanqed
jconv
LATEST```
## Example
### Common example
```Java
import com.github.romanqed.jconv.PipelineBuilders;public class Main {
public static void main(String[] args) throws Throwable {
var builder = PipelineBuilders.createClosed();
var pipeline = builder
// The code below will be executed inside the pipeline in the following order:
.add((c, n) -> {
System.out.println("{ - 1"); // 1
n.run(c);
System.out.println("} - 4"); // 4
})
.add((c, n) -> {
System.out.println(c + " - 2"); // 2
n.run(c - 1);
})
.add((c, n) -> {
System.out.println(c + " - 3"); // 3
})
.add((c, n) -> {
System.out.println(c); // This code will never be executed
})
.build();
pipeline.run(10);
}
}
```This example will print
```
{ - 1
10 - 2
9 - 3
} - 4
```### Exception handling
```Java
import com.github.romanqed.jconv.PipelineBuilders;import java.io.IOException;
public class Main {
public static void main(String[] args) throws Throwable {
var builder = PipelineBuilders.createClosed();
var pipeline = builder
.add((c, n) -> {
try {
n.run(null);
} catch (IOException e) {
System.out.println("Catch IO exception: ");
e.printStackTrace();
}
})
.add((c, n) -> {
var io = new IOException();
throw new IOException(); // Some I/O problem occurs here
})
.build();
pipeline.run(null);
}
}
```This example will print
```
Catch IO exception:
java.io.IOException
at Main.lambda$main$1(Main.java:20)
at com.github.romanqed.jconv/com.github.romanqed.jconv.LinkedRunnable.run(LinkedRunnable.java:26)
at Main.lambda$main$0(Main.java:13)
at com.github.romanqed.jconv/com.github.romanqed.jconv.LinkedRunnable.run(LinkedRunnable.java:26)
at Main.main(Main.java:23)
```### Short-circuiting
```Java
import com.github.romanqed.jconv.PipelineBuilders;public class Main {
public static void main(String[] args) throws Throwable {
var builder = PipelineBuilders.createClosed();
var pipeline = builder
.add((c, n) -> {
if (c > 0) {
n.run(c);
}
})
.add((c, n) -> {
System.out.println(c);
})
.build();
pipeline.run(5); // <-- This call will print "5"
pipeline.run(0); // <-- This call will print nothing
}
}
```## Built With
* [Gradle](https://gradle.org) - Dependency management
* [jfunc](https://github.com/RomanQed/jfunc) - Lambda interfaces## Authors
* **[RomanQed](https://github.com/RomanQed)** - *Main work*
See also the list of [contributors](https://github.com/RomanQed/jconv/contributors)
who participated in this project.## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details