public class ConstructorUtil extends Object
Constructor related utility functions.| Constructor and Description |
|---|
ConstructorUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Constructor<T> |
getConstructor(Class<T> type,
Class<?>[] argTypes)
|
static <T> T |
invokeConstructor(Class<T> type,
Class<?>[] argTypes,
Object[] argValues)
Creates a new instance of the specified
type
using a Constructor described by the given parameter types
and values. |
public static <T> Constructor<T> getConstructor(Class<T> type, Class<?>[] argTypes)
type - the (non-null) type of Object the returned Constructor should createargTypes - a non-null array of types describing the parameters to the Constructor.Constructor for the given method signature, or null
if no such Constructor can be found.invokeConstructor(java.lang.Class<T>, java.lang.Class<?>[], java.lang.Object[])public static <T> T invokeConstructor(Class<T> type, Class<?>[] argTypes, Object[] argValues) throws InstantiationException, IllegalAccessException, InvocationTargetException
type
using a Constructor described by the given parameter types
and values.type - the type of Object to be createdargTypes - a non-null array of types describing the parameters to the Constructor.argValues - a non-null array containing the values of the parameters to the Constructor.type
using a Constructor described by the given parameter types
and values.InstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.