public class ConcreteClassGenerator extends Object
Constructor and Description |
---|
ConcreteClassGenerator() |
Modifier and Type | Method and Description |
---|---|
static <T> Constructor<T> |
getConcreteConstructor(Class<T> abstractClass,
Class<?>... argTypes)
Get the constructor of the concrete, dynamic wrapper class of the given abstract class
with matching argument types.
|
static <T> Class<? extends T> |
makeConcrete(Class<T> abstractClass)
Takes an abstract class and returns a concrete implementation.
|
static <T> T |
newInstance(Class<T> c) |
static <T> T |
newInstance(Class<T> c,
Class<?>[] paramTypes,
Object[] params)
Utility method for safely invoking a constructor that we do
not expect to throw exceptions.
|
static <T,P> T |
newInstance(Class<T> c,
Class<? extends P> paramType,
P param) |
static <T,P1,P2> T |
newInstance(Class<T> c,
Class<? extends P1> paramType1,
P1 param1,
Class<? extends P2> paramType2,
P2 param2) |
static <T,P1,P2,P3> |
newInstance(Class<T> c,
Class<? extends P1> paramType1,
P1 param1,
Class<? extends P2> paramType2,
P2 param2,
Class<? extends P3> paramType3,
P3 param3) |
static <T,P1,P2,P3,P4> |
newInstance(Class<T> c,
Class<? extends P1> paramType1,
P1 param1,
Class<? extends P2> paramType2,
P2 param2,
Class<? extends P3> paramType3,
P3 param3,
Class<? extends P4> paramType4,
P4 param4) |
static <T> T |
newInstance(Constructor<T> cons,
Object... params)
Construct a new instance by the given constructor and its arguments.
|
public static <T> Constructor<T> getConcreteConstructor(Class<T> abstractClass, Class<?>... argTypes) throws ClassNotFoundException
the
- argTypes of the constructor to look for. null signify default constructor.ClassNotFoundException
public static <T> Class<? extends T> makeConcrete(Class<T> abstractClass) throws ClassNotFoundException
AbstractMethodError
.abstractClass
- the abstract classClassNotFoundException
public static <T> T newInstance(Constructor<T> cons, Object... params)
public static <T> T newInstance(Class<T> c, Class<?>[] paramTypes, Object[] params)
c
- the class to constructparamTypes
- the types of the parametersparams
- the parameter valuespublic static <T> T newInstance(Class<T> c)
public static <T,P1,P2> T newInstance(Class<T> c, Class<? extends P1> paramType1, P1 param1, Class<? extends P2> paramType2, P2 param2)
public static <T,P1,P2,P3> T newInstance(Class<T> c, Class<? extends P1> paramType1, P1 param1, Class<? extends P2> paramType2, P2 param2, Class<? extends P3> paramType3, P3 param3)
Copyright © 2006–2017 Apache Software Foundation. All rights reserved.