Пример #1
0
 /**
  * 填充 map .<br>
  * 在map中使用hash值来做为key来进行存储
  *
  * @param klass
  * @param settingMap
  * @throws InstantiationException
  * @throws IllegalAccessException
  * @throws IllegalArgumentException
  * @throws InvocationTargetException
  */
 private void fillMap(Class<?> klass, HashMap<Class<?>, Method> settingMap)
     throws InstantiationException, IllegalAccessException, IllegalArgumentException,
         InvocationTargetException {
   Castor<?, ?> castor = (Castor<?, ?>) klass.newInstance();
   if (!map.containsKey(castor.hashCode())) {
     map.put(castor.hashCode(), castor);
   }
   Method m = settingMap.get(castor.getClass());
   if (null == m) {
     for (Entry<Class<?>, Method> entry : settingMap.entrySet()) {
       Class<?> cc = entry.getKey();
       if (cc.isAssignableFrom(klass)) {
         m = settingMap.get(cc);
         break;
       }
     }
   }
   if (null != m) m.invoke(setting, castor);
 }