I use the builder pattern to make an object. The problem is that I have to get arguments from command line. I want to pass one to six arguments and, based on the arguments amount, call the relevant methods.
For example, if I pass 3 args, the program will call first three methods; first four methods for 4 args and so on;
ExampleClass obj = new ExampleClass.Builder()
.method1(args[0])
.method2(args[1])
.method3(args[2])
.build();
Is it even possible to make it efficiently? The only thing that occurs to me is reflection, but I'm not sure if this is a good idea.