(Object value, Class<?> type)
| 57 | } |
| 58 | |
| 59 | private static Object convertTo(Object value, Class<?> type) { |
| 60 | // value의 타입과 type의 타입이 같으면 그대로 반환 |
| 61 | if(value==null || type==null || type.isInstance(value)) |
| 62 | return value; |
| 63 | |
| 64 | // value의 타입과 type이 다르면, 변환해서 반환 |
| 65 | if(String.class.isInstance(value) && type==int.class) // String -> int |
| 66 | return Integer.valueOf(""+value); |
| 67 | |
| 68 | return value; |
| 69 | } |
| 70 | |
| 71 | // iv의 이름으로 setter의 이름을 만들어서 반환하는 메서드("day" -> "setDay") |
| 72 | private static String getSetterName(String name) { |