#Parsing config arguments depending on class properties

4 messages · Page 1 of 1 (latest)

pulsar rain
#

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.

valid dewBOT
#

This post has been reserved for your question.

Hey @pulsar rain! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

valid dewBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.