I came across similar kind of solution to my problem but I need further info. According to my use case, I have created a method which takes two parameters in which one is required and the other is optional.
public void myMethod(Required req){ ... }
In my application there are lot of methods calling myMethod. I need to update it by adding one more not-required parameter to myMethod as in:
public void myMethod(Required req, NotRequired nr){ ... }
I want to add one optional parameter without affecting the pre-existing caller methods. I mean to say is that I want to call myMethod using the following ways:
Required req = new Required();
NotRequired nr = new NotRequired();
myMethod(req);
myMethod(nr);
I came across java optional parameter in methods which made me think that it is only possible in Java using Builder pattern but I guess my case here is pretty different. If it can be done any suggestions will be appreciated!