Scenario:
- I have two classes named ListLayout and GridLayout which both implement CustomLayout.
- The user enters a String representing the layout they wish to use ("ListLayout" for example)
How can I create a ListLayout object based on the string entered by the user? I would need to be equivalent to just doing this:
CustomLayout layout = new ListLayout();
Ideally I would need to find a solution which would allow me to check if the String entered corresponds to a predefined class which implements CustomLayout before actually making the object (because it will throw an error if it doesn't exist and I don't check beforehand).
This is really getting me thinking.... thanks in advance for your help