Re-adding Reflection2.constructor

Removed in 671749d but used downstream in jclouds-labs
This commit is contained in:
Andrew Phillips 2014-10-26 19:14:49 -04:00
parent c426e7ec24
commit 2a5928b55d
1 changed files with 17 additions and 0 deletions

View File

@ -71,6 +71,23 @@ public class Reflection2 {
return (TypeToken<T>) get(typeTokenForClass, checkNotNull(in, "class"));
}
/**
* returns an {@link Invokable} object that reflects a constructor present in the {@link TypeToken} type.
*
* @param ownerType
* corresponds to {@link Invokable#getOwnerType()}
* @param parameterTypes
* corresponds to {@link Constructor#getParameterTypes()}
*
* @throws IllegalArgumentException
* if the constructor doesn't exist or a security exception occurred
*/
@SuppressWarnings("unchecked")
public static <T> Invokable<T, T> constructor(Class<T> ownerType, Class<?>... parameterTypes) {
return (Invokable<T, T>) get(constructorForParams, new TypeTokenAndParameterTypes(typeToken(ownerType),
parameterTypes));
}
/**
* return all constructors present in the class as {@link Invokable}s.
*