Package play.libs.reflect
Class ConstructorUtils
java.lang.Object
play.libs.reflect.ConstructorUtils
Imported from apache.commons.lang3 3.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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.
-
Constructor Details
-
ConstructorUtils
public ConstructorUtils()
-
-
Method Details
-
getAccessibleConstructor
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,
nullif no matching accessible constructor found - Throws:
NullPointerException- ifctorisnull- See Also:
-
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, notnullparameterTypes- find method with compatible parameters- Returns:
- the constructor, null if no matching accessible constructor found
- Throws:
NullPointerException- ifclsisnull
-