将一个Bean的数据装换到另外一个（需实现setter和getter，以及一个默认无参构造函数）

@param object 一个Bean
@param clazz 另外一个Bean
@param <T> 另外Bean类型

@return {@link T}

@throws InstantiationException 异常
@throws IllegalAccessException 异常
@throws InvocationTargetException 异常
@since 1.1.1
183354
public static <T> T bean2Another(Object object, Class<T> clazz) throws IllegalAccessException,
            InstantiationException, InvocationTargetException {
        return bean2Another(object, clazz, clazz.newInstance());
    }
89451
@SuppressWarnings("unchecked")
	private Set<Class<? extends T>> findScriptClass(Set<Class<?>> clazzs)
			throws InstantiationException, IllegalAccessException {
		Set<Class<? extends T>> scriptClazzs = new HashSet<Class<? extends T>>();
		for (Class<?> clazz : clazzs) {
			Class<T> scriptClazz = null;
			try {
				scriptClazz=(Class<T>) clazz;
			}catch (Throwable e) {
			}
			if(scriptClazz==null)
			{
				continue;
			}
			if(acceptClass(scriptClazz))
			{
				scriptClazzs.add(scriptClazz);
			}
			//如果A接口有B,C实现,B和C之间不能转换,如果T是B,则不能使用A.class.isAssignableFrom(clazz)判断
//			if (IScript.class.isAssignableFrom(clazz)) {
//				Class<T> scriptClazz = (Class<T>) clazz;
//				scriptClazzs.add(scriptClazz);
//			}
		}
		return scriptClazzs;
	}
261689
public Annotator getAnnotator(Class<? extends Annotator> clazz) {

        if (!Annotator.class.isAssignableFrom(clazz)) {
            throw new IllegalArgumentException("The class name given as a custom annotator (" + clazz.getName() + ") does not refer to a class that implements " + Annotator.class.getName());
        }

        try {
            try {
                Constructor<? extends Annotator> constructor = clazz.getConstructor(GenerationConfig.class);
                return constructor.newInstance(generationConfig);
            } catch (NoSuchMethodException e) {
                return clazz.newInstance();
            }
        } catch (InvocationTargetException | InstantiationException e) {
            throw new IllegalArgumentException("Failed to create a custom annotator from the given class. An exception was thrown on trying to create a new instance.", e.getCause());
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Failed to create a custom annotator from the given class. It appears that we do not have access to this class - is both the class and its no-arg constructor marked public?", e);
        }

    }
892728
@SuppressWarnings("unchecked")
	public static <T> T newInstance(String clazz) throws UtilException {
		try {
			return (T) Class.forName(clazz).newInstance();
		} catch (Exception e) {
			throw new UtilException(e, "Instance class [{}] error!", clazz);
		}
	}
732659
public static <T> void setProperty(Object bean, String name, Class<T> clazz, T value) throws Exception {
        Method method = ReflectUtils.getPropertySetterMethod(bean.getClass(), name, clazz);
        if (method.isAccessible()) {
            method.invoke(bean, value);
        } else {
            try {
                method.setAccessible(true);
                method.invoke(bean, value);
            } finally {
                method.setAccessible(false);
            }
        }
    }
744600
public <T> T convert(Object object, Class<T> clazz) {
        if (object == null) {
            return null;
        }

        return mapper.convertValue(object, clazz);
    }
258383
public static Object loadInstance(Class clazz, Object[] args) throws ClassException, InvocationTargetException {
	if (args == null || args.length == 0) return loadInstance(clazz);

	Class[] cArgs = new Class[args.length];
	for (int i = 0; i < args.length; i++) {
	    cArgs[i] = args[i].getClass();
	}

	try {
	    Constructor c = clazz.getConstructor(cArgs);
	    return c.newInstance(args);

	}
	catch (SecurityException e) {
	    throw new ClassException("there is a security violation (throwed by security manager)");
	}
	catch (NoSuchMethodException e) {

	    StringBuilder sb = new StringBuilder(clazz.getName());
	    char del = '(';
	    for (int i = 0; i < cArgs.length; i++) {
		sb.append(del);
		sb.append(cArgs[i].getName());
		del = ',';
	    }
	    sb.append(')');

	    throw new ClassException("there is no constructor with this [" + sb + "] signature for the class [" + clazz.getName() + "]");
	}
	catch (IllegalArgumentException e) {
	    throw new ClassException("has been passed an illegal or inappropriate argument");
	}
	catch (InstantiationException e) {
	    throw new ClassException("the specified class object [" + clazz.getName() + "] cannot be instantiated because it is an interface or is an abstract class");
	}
	catch (IllegalAccessException e) {
	    throw new ClassException("can't load class because the currently executing method does not have access to the definition of the specified class");
	}
    }
65536
public Object createObject(String className, Class clazz) throws ClassNotFoundException {
        Object object;
        try {
            object = clazz.newInstance();

        } catch (InstantiationException ie) {
            String info = "Could not create " + description + " object: " + className
                    + ". Could not access object constructor: ";
            info += ie.getMessage();
            throw new ClassNotFoundException(info, ie);

        } catch (IllegalAccessException iae) {
            String info = "Could not create " + description + " object: " + className
                    + ". Could not instantiate object. Does the object classname refer to an abstract class, "
                    + "an interface or the like?: ";
            info += iae.getMessage();
            throw new ClassNotFoundException(info, iae);

        } catch (ClassCastException cce) {
            String info = "Could not create " + description + " object: " + className
                    + ". The specified object classname does not refer to the proper type: ";
            info += cce.getMessage();
            throw new ClassNotFoundException(info, cce);
        }

        return object;
    }
1190586
@SuppressWarnings("unchecked")
    public static <T extends Annotation> T createAnnotation(final Class<T> clazz) {
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz, Annotation.class}, new SimpleAnnoInvocationHandler(clazz));
    }
733812
public <T> T execute(final Object[] args, final Class<T> clazz) {
        return execute(args, clazz, true);
    }
1315241
public static Object loadInstance(Class clazz, Object[] args, Object defaultValue) {
	if (args == null || args.length == 0) return loadInstance(clazz, defaultValue);
	try {
	    Class[] cArgs = new Class[args.length];
	    for (int i = 0; i < args.length; i++) {
		if (args[i] == null) cArgs[i] = Object.class;
		else cArgs[i] = args[i].getClass();
	    }
	    Constructor c = clazz.getConstructor(cArgs);
	    return c.newInstance(args);

	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	    return defaultValue;
	}

    }
892287
public static <T> T newInstance(Class<T> clazz) throws MjdbcException {
        try {
            return clazz.newInstance();

        } catch (InstantiationException ex) {
            throw new MjdbcException(
                    "Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());

        } catch (IllegalAccessException ex) {
            throw new MjdbcException(
                    "Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());
        }
    }
1066205
public static <T> T get(Class<T> clazz, String sql, Object... arg) {
        List<T> list = DBUtils.getList(clazz, sql, arg);
        if (list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }
818483
@Override
  public <T extends BaseProxy> T create(final Class<T> clazz) {
    this.checkLocked();

    final SimpleProxyId<T> id = this.state.requestFactory.allocateId(clazz);
    final AutoBean<T> created = this.createProxy(clazz, id, false);
    return this.takeOwnership(created);
  }
1153042
public static <T> T getBean(Class<T> clazz) {
        return getSenBotContext().context.getBean(clazz);
    }
854534
public Object create(String name, Object... args)
    throws ClassNotFoundException,
           NoSuchMethodException,
           IllegalAccessException,
           InstantiationException,
           InvocationTargetException
    {
//StringBuilder sb = new StringBuilder("DefaultObjectFactory.create(").append(name).append(',');
//for (Object arg: args) {
//sb.append(arg.getClass().getName()).append(' ');
//}
//sb.append(')');
//System.err.println(sb);
        try {
            Class<?> type = Class.forName(name);
/*
            Constructor<?>[] constructors = type.getConstructors();
            for (Constructor<?> constructor: constructors) {
                Class<?>[] ptypes = constructor.getParameterTypes();
                if (ptypes.length == args.length) {
                    try {
                        return constructor.newInstance(args);
                    } catch (IllegalArgumentException x) {
                        // ignore and try the next one
                    } catch (IllegalAccessException x) {
                        throw x;
                    } catch (InstantiationException x) {
                        throw x;
                    } catch (InvocationTargetException x) {
                        throw x;
                    }
                }
            }
            throw new NoSuchMethodException("Can't locate a desired constructor in " + name);
*/
//System.err.println("DefaultObjectFactory.create: successful");
            return Beans.create(type, args);
        } catch (ClassNotFoundException x) {
            throw x;
        }
    }
71545
public static Object initialize(Class clazz, Object record)
    {
        try
        {
            if (record == null)
            {
                record = createNewInstance(clazz);
            }
            return record;
        }
        catch (Exception e)
        {
            throw new PersistenceException("Error occured while instantiating entity.", e);
        }
    }