public class Signatures extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ANY |
static int |
NONE |
static int |
NOT_DEFAULT |
static int |
PRIVATE |
static int |
PROTECTED |
static int |
PUBLIC |
static int |
STATIC |
| Constructor and Description |
|---|
Signatures() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
best(T[] items,
Class<?>[][] signatures,
boolean[] varArgs,
Class<?>[] argTypes)
Selects the best item for the given argument types.
|
static <T> Constructor<T> |
bestConstructor(Class<T> clazz,
Class<?>[] argTypes)
Finds the best constructor for the given arguments types.
|
static <T> Constructor<T> |
bestConstructor(Class<T> clazz,
Object[] args)
Finds the best constructor for the given arguments.
|
static <T> Constructor<T> |
bestConstructor(Constructor<T>[] constructors,
Class<?>[] argTypes)
Selects the best constructor for the given argument types.
|
static <T> Constructor<T> |
bestConstructor(Constructor<T>[] constructors,
Object[] args)
Selects the best constructor for the given arguments.
|
static int |
bestMatch(Class<?>[][] signatures,
boolean[] varArgs,
Class<?>[] argTypes)
Selects the best match in signatures for the given argument types.
|
static int |
bestMatch(Class<?>[][] signatures,
boolean[] varArgs,
JavaSignatureComparator jsCmp) |
static Method |
bestMethod(Class<?> clazz,
String name,
Class<?>[] argTypes)
Finds the best method for the given argument types.
|
static Method |
bestMethod(Class<?> clazz,
String name,
Object[] args)
Finds the best method for the given arguments.
|
static Method |
bestMethod(Method[] methods,
Class<?>[] argTypes)
Selects the best method for the given argument types.
|
static Method |
bestMethod(Method[] methods,
Object[] args)
Selects the best method for the given arguments.
|
static <T> Constructor<T>[] |
candidateConstructors(Class<T> clazz,
Class<?>[] argTypes)
Finds the best equally-matching constructors for the given argument types.
|
static <T> Constructor<T>[] |
candidateConstructors(Class<T> clazz,
Object[] args)
Finds the best equally-matching constructors for the given arguments.
|
static <T> Constructor<T>[] |
candidateConstructors(Constructor<T>[] constructors,
Class<?>[] argTypes)
Selects the best equally-matching constructors for the given argument types.
|
static <T> Constructor<T>[] |
candidateConstructors(Constructor<T>[] constructors,
Object[] args)
Selects the best equally-matching constructors for the given arguments.
|
static int[] |
candidateMatches(Class<?>[][] signatures,
boolean[] varArgs,
Class<?>[] argTypes)
Returns indices of all signatures that are a best match for the given
argument types.
|
static int[] |
candidateMatches(Class<?>[][] signatures,
boolean[] varArgs,
JavaSignatureComparator jsCmp) |
static Method[] |
candidateMethods(Class<?> clazz,
String name,
Class<?>[] argTypes)
Finds the best equally-matching methods for the given argument types.
|
static Method[] |
candidateMethods(Class<?> clazz,
String name,
Object[] args)
Finds the best equally-matching methods for the given arguments.
|
static Method[] |
candidateMethods(Method[] methods,
Class<?>[] argTypes)
Selects the best equally-matching methods for the given argument types.
|
static Method[] |
candidateMethods(Method[] methods,
Object[] args)
Selects the best equally-matching methods for the given arguments.
|
static <T> T[] |
candidates(T[] items,
Class<?>[][] signatures,
boolean[] varArgs,
Class<?>[] argTypes)
Selects the best equally-matching item for the given argument types.
|
static Class<?>[] |
collectArgTypes(Collection<?> args) |
static Class<?>[] |
collectArgTypes(Object[] args)
Returnes the types for all values.
|
static void |
collectArgTypes(Object[] args,
Class<?>[] types,
int argIndex,
int typeIndex,
int length) |
static <T> Constructor<T>[] |
collectConstructors(Class<T> clazz)
Collects all public constructors of
clazz. |
static <T> Constructor<T>[] |
collectConstructors(Class<T> clazz,
int include,
int exclude)
Collects constructors of
clazz. |
static Method[] |
collectMethods(Class<?> clazz,
String name)
Collects all public methods of
clazz with the given name. |
static Method[] |
collectMethods(Class<?> clazz,
String name,
int include,
int exclude)
Collects methods of
clazz with the given name. |
static Class<?>[][] |
collectSignatures(Constructor<?>[] constructors) |
static Class<?>[][] |
collectSignatures(Method[] methods) |
static boolean[] |
collectVarArgs(Constructor<?>[] constructors) |
static boolean[] |
collectVarArgs(Method[] methods) |
static Object[] |
fixVarArgs(Class<?>[] paramsWithVarArgs,
Object[] arguments)
Fixes an arguments array to fit parameter types,
where the last parameter is an varargs array.
|
static Object[] |
fixVarArgs(int length,
Class<?> varArgType,
Object[] arguments)
Fixes an arguments array to fit a given length,
the last value is an array filled with varargs.
|
static Object |
invoke(Object instance,
Method method,
Object... args)
Invokes
method, automatically tries to fix varargs arguments. |
static <T> T |
newInstance(Constructor<T> constructor,
Object... args)
Invokes
constructor, automatically tries to fix varargs arguments. |
public static final int NONE
public static final int ANY
public static final int STATIC
public static final int PRIVATE
public static final int PROTECTED
public static final int PUBLIC
public static final int NOT_DEFAULT
public static <T> Constructor<T> bestConstructor(Class<T> clazz, Object[] args) throws AmbiguousConstructorMatchException
T - clazz - args - nullAmbiguousSignatureMatchException - if multiple constructors match equallyAmbiguousConstructorMatchExceptionpublic static <T> Constructor<T> bestConstructor(Class<T> clazz, Class<?>[] argTypes) throws AmbiguousConstructorMatchException
T - clazz - argTypes - nullAmbiguousSignatureMatchException - if multiple constructors match equallyAmbiguousConstructorMatchExceptionpublic static <T> Constructor<T> bestConstructor(Constructor<T>[] constructors, Object[] args) throws AmbiguousConstructorMatchException
T - constructors - args - nullAmbiguousSignatureMatchException - if multiple constructors match equallyAmbiguousConstructorMatchExceptionpublic static <T> Constructor<T> bestConstructor(Constructor<T>[] constructors, Class<?>[] argTypes) throws AmbiguousConstructorMatchException
T - constructors - argTypes - nullAmbiguousSignatureMatchException - if multiple constructors match equallyAmbiguousConstructorMatchExceptionpublic static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Object[] args)
T - clazz - args - public static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Class<?>[] argTypes)
T - clazz - argTypes - public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Object[] args)
T - constructors - args - public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Class<?>[] argTypes)
T - constructors - argTypes - public static Method bestMethod(Class<?> clazz, String name, Object[] args) throws AmbiguousMethodMatchException
clazz - name - args - AmbiguousSignatureMatchException - if multiple methods match equallyAmbiguousMethodMatchExceptionpublic static Method bestMethod(Class<?> clazz, String name, Class<?>[] argTypes) throws AmbiguousMethodMatchException
clazz - name - argTypes - AmbiguousSignatureMatchException - if multiple methods match equallyAmbiguousMethodMatchExceptionpublic static Method bestMethod(Method[] methods, Object[] args) throws AmbiguousMethodMatchException
methods - args - AmbiguousSignatureMatchException - if multiple methods match equallyAmbiguousMethodMatchExceptionpublic static Method bestMethod(Method[] methods, Class<?>[] argTypes) throws AmbiguousMethodMatchException
methods - argTypes - AmbiguousSignatureMatchException - if multiple methods match equallyAmbiguousMethodMatchExceptionpublic static Method[] candidateMethods(Class<?> clazz, String name, Object[] args)
clazz - name - args - public static Method[] candidateMethods(Class<?> clazz, String name, Class<?>[] argTypes)
clazz - name - argTypes - public static Method[] candidateMethods(Method[] methods, Object[] args)
methods - args - public static Method[] candidateMethods(Method[] methods, Class<?>[] argTypes)
methods - argTypes - public static <T> T best(T[] items,
Class<?>[][] signatures,
boolean[] varArgs,
Class<?>[] argTypes)
throws AmbiguousSignatureMatchException
T - items - signatures - varArgs - argTypes - AmbiguousSignatureMatchException - if multiple methods match equallypublic static <T> T[] candidates(T[] items,
Class<?>[][] signatures,
boolean[] varArgs,
Class<?>[] argTypes)
T - items - signatures - varArgs - argTypes - public static Class<?>[] collectArgTypes(Collection<?> args)
public static Class<?>[] collectArgTypes(Object[] args)
null-values, the type is null.args - public static void collectArgTypes(Object[] args, Class<?>[] types, int argIndex, int typeIndex, int length)
public static Method[] collectMethods(Class<?> clazz, String name)
clazz with the given name.clazz - name - public static Method[] collectMethods(Class<?> clazz, String name, int include, int exclude)
clazz with the given name.
Methods are included if their modifier bits match each bit of include
and no bit of exclude.clazz - name - include - exclude - public static <T> Constructor<T>[] collectConstructors(Class<T> clazz)
clazz.T - clazz - public static <T> Constructor<T>[] collectConstructors(Class<T> clazz, int include, int exclude)
clazz.
Constructors are included if their modifier bits match each bit of include
and no bit of exclude.T - clazz - include - exclude - public static boolean[] collectVarArgs(Method[] methods)
public static Class<?>[][] collectSignatures(Constructor<?>[] constructors)
public static boolean[] collectVarArgs(Constructor<?>[] constructors)
public static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException
signatures - varArgs - argTypes - AmbiguousSignatureMatchException - if two signatures matched equallypublic static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, JavaSignatureComparator jsCmp) throws AmbiguousSignatureMatchException
signatures - varArgs - jsCmp - AmbiguousSignatureMatchExceptionbestMatch(java.lang.Class[][], boolean[], java.lang.Class[])public static int[] candidateMatches(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes)
signatures - varArgs - argTypes - public static int[] candidateMatches(Class<?>[][] signatures, boolean[] varArgs, JavaSignatureComparator jsCmp)
signatures - varArgs - jsCmp - candidateMatches(java.lang.Class[][], boolean[], java.lang.Class[])public static Object[] fixVarArgs(Class<?>[] paramsWithVarArgs, Object[] arguments)
paramsWithVarArgs - arguments - public static Object[] fixVarArgs(int length, Class<?> varArgType, Object[] arguments)
length - varArgType - arguments - public static <T> T newInstance(Constructor<T> constructor, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException
constructor, automatically tries to fix varargs arguments.T - constructor - args - IllegalAccessExceptionInvocationTargetExceptionInstantiationExceptionpublic static Object invoke(Object instance, Method method, Object... args) throws IllegalAccessException, InvocationTargetException
method, automatically tries to fix varargs arguments.instance - method - args - IllegalAccessExceptionInvocationTargetExceptionCopyright © 2015. All rights reserved.