示例#1
0
 public ObjectWrapper getWrapper(Class clazz) {
   ObjectWrapper ret;
   String classname = clazz.getName();
   if (handlers != null && handlers.containsKey(classname)) ret = initWrapper(classname, clazz);
   else {
     if (Map.class.isAssignableFrom(clazz)) ret = new DefaultMapWrapper(clazz);
     else if (Collection.class.isAssignableFrom(clazz)) ret = new DefaultCollectionWrapper(clazz);
     else if (clazz.isArray()) ret = new ArrayWrapper(clazz);
     else if (ReflectionUtil.isSimpleType(clazz)) return new DefaultSimpleTypeWrapper(clazz);
     else if (clazz.isEnum()) ret = new EnumWrapper(clazz);
     else ret = new DefaultBeanWrapper(clazz);
   }
   ret.setYamlConfig(this);
   return ret;
 }
示例#2
0
 void install(String classname, Object wrapperSpec) {
   if (wrapperSpec instanceof ObjectWrapper) ((ObjectWrapper) wrapperSpec).setYamlConfig(this);
   if (!handlers.containsKey(classname)) handlers.put(classname, wrapperSpec);
 }