For example, given an interface "IPerson":
interface IPerson { String getName(); Integer getAge(); }Use the following to create an instance of IPerson that returns "Ali" for name and 32 for age:
MapThe getterMap should provide a return value for all "get...()" and "is...()" methods from the interface. If an attempt is make to read a value from an interface method for which the getterMap does not specify a value, an Exception will be thrown.getterMap = new HashMap (); getterMap.put("name", "Ali"); getterMap.put("age", new Integer(32)); ClassMaker maker = new ClassMaker(); IPerson instance = (IPerson)maker.makeInstance(IPerson.class, getterMap);
@author bmodi
|
|