Constructor
Constructor Manipulation using Mirror.
Reflecting
Reflecting a constructor by arguments (will return null if not found):
Class<T> clazz;
Constructor<T> c = new Mirror().on(clazz).reflect().constructor()
.withArgs(String.class, Object.class);
Reflecting all constructors of a class (will return an empty list if none found):
Class<T> clazz;
List<Constructor<T>> l = new Mirror().on(clazz).reflectAll().constructors();
Reflecting all constructors of a class that matches a Matcher<Constructor> (will return an empty list if none found):
Class<T> clazz;
List<Constructor<T>> l = new Mirror().on(clazz).reflectAll()
.constructorsMatching(new YourCustomMatcher());
Invoking Constructors
Invoking a constructor:
Class<T> clazz;
T t = new Mirror().on(clazz).invoke().constructor().withoutArgs();
You can also pass a java.lang.reflect.Constructor:
Constructor<T> aConstructor;
Class<T> clazz;
T t = new Mirror().on(clazz).invoke().constructor(aConstructor).withArgs(value1, value2);