Package play.libs.reflect
Class ConstructorUtils
- Object
-
- play.libs.reflect.ConstructorUtils
-
public class ConstructorUtils extends Object
Imported from apache.commons.lang3 3.6
-
-
Constructor Summary
Constructors Constructor Description ConstructorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Constructor<T>
getAccessibleConstructor(Constructor<T> ctor)
Checks if the specified constructor is accessible.static <T> Constructor<T>
getMatchingAccessibleConstructor(Class<T> cls, Class<?>... parameterTypes)
Finds an accessible constructor with compatible parameters.
-
-
-
Method Detail
-
getAccessibleConstructor
public static <T> Constructor<T> getAccessibleConstructor(Constructor<T> ctor)
Checks if the specified constructor is accessible.This simply ensures that the constructor is accessible.
- Type Parameters:
T
- the constructor type- Parameters:
ctor
- the prototype constructor object, notnull
- Returns:
- the constructor,
null
if no matching accessible constructor found - Throws:
NullPointerException
- ifctor
isnull
- See Also:
SecurityManager
-
getMatchingAccessibleConstructor
public static <T> Constructor<T> getMatchingAccessibleConstructor(Class<T> cls, Class<?>... parameterTypes)
Finds an accessible constructor with compatible parameters.This checks all the constructor and finds one with compatible parameters This requires that every parameter is assignable from the given parameter types. This is a more flexible search than the normal exact matching algorithm.
First it checks if there is a constructor matching the exact signature. If not then all the constructors of the class are checked to see if their signatures are assignment-compatible with the parameter types. The first assignment-compatible matching constructor is returned.
- Type Parameters:
T
- the constructor type- Parameters:
cls
- the class to find a constructor for, notnull
parameterTypes
- find method with compatible parameters- Returns:
- the constructor, null if no matching accessible constructor found
- Throws:
NullPointerException
- ifcls
isnull
-
-