| 10 | |
| 11 | public class SetterCall { |
| 12 | public static void main(String[] args) throws Exception{ |
| 13 | Map<String, String> map = new HashMap<>(); |
| 14 | map.put("year", "2021"); |
| 15 | map.put("month", "10"); |
| 16 | map.put("day", "1"); |
| 17 | |
| 18 | Class<?> type = Class.forName("com.fastcampus.ch2.MyDate"); |
| 19 | |
| 20 | // MyDate인스턴스를 생성하고, map의 값으로 초기화한다. |
| 21 | Object obj = dataBind(map, type); |
| 22 | System.out.println("obj="+obj); // obj=[year=2021, month=10, day=1] |
| 23 | } // main |
| 24 | |
| 25 | private static Object dataBind(Map<String, String> map, Class<?> clazz) throws Exception { |
| 26 | // 1. MyDate인스턴스 생성 |