I have a one Command Interface like this,
public interface ICommand{
public abstract Object execute(List<Inputs> inputs);
}
Now I have A command for other type of complex Executions so I came up with the new Command Interface
public interface IComplexCommand {
public abstract Object execute(ComplexObjects obj);
}
I invoke the commands from the properties file which is done inside a static initializer block of CommandFactory. My Factory method to Invoke looks like this.
ICommand cmd= CommandFactory.getInstance().getCommand("LoopElements");
// loopElements is the key in properties file to load my com.test.my.LoopElements
// to call execute of IComplex command it will not work because I have to typecase
// this I want to avoid.
Now I have a issue like when I get the Command I do not want to typecase the Command depending on Interface but I would like to have it understood at runtime,
Can anyone please help me in better designing this. I tried to google but I was not able to get any proper answer because the question is very specific.