public class ObjectFactory extends Object
Constructor and Description |
---|
ObjectFactory() |
Modifier and Type | Method and Description |
---|---|
static Object[] |
filterParameters(Parameter[] parameters,
Object[] parameterValues)
Filter parameter values that has the necessary types.
|
static Class<?>[] |
getClassTree(Class<?> clss)
Get super classes and interfaces implemented by the given class
|
static Constructor<? extends Object> |
getConstructor(Class<? extends Object> objectClass,
Class<?>[] parameterClasses)
Get the constructor for a class that matches the given parameter classes.
|
protected static Class<?>[] |
getParameterClasses(Object... constructorParameters)
Get an array with the classes of the given parameters
|
protected static Set<Class<?>> |
getSubclassesOf(Package pkg,
Class<?> superClass) |
static String |
signature(Class<? extends Object> objectClass,
Class<?>[] parameterClasses)
Generate a String which represent the signature of the given classes.
|
protected static Constructor<? extends Object> |
tryConstructor(Class<? extends Object> objectClass,
Class<?>... parameterClasses) |
public static Constructor<? extends Object> getConstructor(Class<? extends Object> objectClass, Class<?>[] parameterClasses) throws IllegalArgumentException
Get the constructor for a class that matches the given parameter classes.
objectClass
- Class<? extends Object>parameterClasses
- Class<?>[]IllegalArgumentException
- If more than one constructor is suitable for the given arguments but its signature does not exactly match the classes of the parameterspublic static Object[] filterParameters(Parameter[] parameters, Object[] parameterValues) throws InstantiationException
Filter parameter values that has the necessary types.
Case 1. If parameters.length is equal to parameterValues.length then the types of parameterValues will be checked to match the ones specified at parameters. If the types do not match then InstantiationException will be thrown. If the types match then parameterValues will be returned.
Case 2. If parameters.length is less than parameterValues.length then the first n parameter values with the same types as parameters will be returned.
Case 3. If parameters.length is greater than parameterValues.length then InstantiationException will be thrown.
parameters
- Parameter[]parameterValues
- Object[]InstantiationException
protected static Class<?>[] getParameterClasses(Object... constructorParameters)
constructorParameters
- Object…public static String signature(Class<? extends Object> objectClass, Class<?>[] parameterClasses)
objectClass
- Class<? extends Object>parameterClasses
- Class<?>[]public static Class<?>[] getClassTree(Class<?> clss)
clss
- Class<?>protected static Constructor<? extends Object> tryConstructor(Class<? extends Object> objectClass, Class<?>... parameterClasses)
protected static Set<Class<?>> getSubclassesOf(Package pkg, Class<?> superClass) throws RuntimeException
RuntimeException
Copyright © 2001–2019 KnowGate. All rights reserved.