I am writing a "pipeline" using the functional interface and chaining functions using ".andThen". Each of these functions are seperate classes just extending the the function interface.
An example for such class is the following:
public class FileSaveModule implements ModuleBase<String, String> {
private final String destination;
public FileSaveModule(String destination) {
this.destination = destination;
}
@Override
public String process(String input) {
File outputFile = new File(this.destination);
//.. do logic and return something
}
}
This works just fine but it requires me to initialize the class with required arguments, like the destination in this example. I now want to be able to load the pipeline and therefor its required args from a config file like this:
modules=load,encrypt,save
save.destination=out.enc.txt
I am aware of how to solve this using static conditions, but I want to load the arguments in the config in a dynamic way, but I seem to get stuck finding a fancy way of doing it.
My idea was that I could just use Annotation to handle metadata about properties:
e.g.
@Argument
private String destination;
...but that seems to get really messy especially if there is a more complex structure in the modules.
My goal is that if someone would write a module like the one above he wouldnt have to worry about actually implementing the logic to load arguments by himself.