public class UtilJava extends Object
| 构造器和说明 |
|---|
UtilJava() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Constructor<?> |
getConstructor(Class<?> cls,
Object... objects)
根据参数获取相应的构造函数。
|
static <T> Iterable<T> |
getIterable(Object collection)
把指定对象转换成Iterable,如果是数据或Iterable本身的条目也是返回的Iteralbe的条目,
null返回一个空List,其他包装成一个Iterable,把对象放到Iterable条目中。
|
static <T> Iterator<T> |
getIterator(Object collection) |
static Method |
getMethod(Class<?> cls,
String methodName,
List<Object> params)
通过参数值列表获取对象的方法。
|
static Object |
invokeMethod(String className,
String methodName,
ActionContext actionContext)
调用参数是ActionContext的静态方法。
|
static Object |
invokeMethod(String className,
String methodName,
Class<?>[] paramTypes,
Object[] args)
调用参数是ActionContext的静态方法。
|
static <T> T |
newInstance(String className,
Object... objects)
一个简单的实例化对象的方法。
|
public static <T> Iterable<T> getIterable(Object collection)
collection - 集合public static Method getMethod(Class<?> cls, String methodName, List<Object> params)
cls - 类methodName - 方法名称params - 参数public static Object invokeMethod(String className, String methodName, ActionContext actionContext) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException
className - 类名methodName - 方法名actionContext - 变量上下文InvocationTargetExceptionIllegalArgumentExceptionIllegalAccessExceptionSecurityExceptionNoSuchMethodExceptionClassNotFoundExceptionpublic static Object invokeMethod(String className, String methodName, Class<?>[] paramTypes, Object[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException
className - 类名methodName - 方法名paramTypes - 参数类型args - 参数列表InvocationTargetExceptionIllegalArgumentExceptionIllegalAccessExceptionSecurityExceptionNoSuchMethodExceptionClassNotFoundExceptionpublic static <T> T newInstance(String className, Object... objects) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
className - 类名objects - 参数列表ClassNotFoundExceptionInvocationTargetExceptionIllegalArgumentExceptionIllegalAccessExceptionInstantiationExceptionpublic static Constructor<?> getConstructor(Class<?> cls, Object... objects)
cls - objects - Copyright © 2022 xworker.org. All rights reserved.