Java Utililty Methods Reflection Method Get from Object

List of utility methods to do Reflection Method Get from Object

Description

The list of methods to do Reflection Method Get from Object are organized into topic(s).

Method

TgetMethodConfigByAnnotaton(Object instance, Class declaringClass, Class annotationType, Class type)
get Method Config By Annotaton
T result = null;
List<Method> methods = new ArrayList<>();
methods.addAll(Arrays.asList(declaringClass.getDeclaredMethods()));
methods.addAll(Arrays.asList(declaringClass.getMethods()));
for (Method method : methods) {
    Annotation anno = method.getAnnotation(annotationType);
    if (anno != null) {
        method.setAccessible(true);
...
MethodgetMethodDescriptor(Object instance, String methodName, Class aClass, Class... parameters)
get Method Descriptor
notNull(instance, "instance");
Method method = aClass.getDeclaredMethod(methodName, parameters);
method.setAccessible(true);
return method;
ClassgetMethodFirstParamType(final String methodName, final Object o)
get Method First Param Type
Class firstParamType = null;
Method[] methods = o.getClass().getMethods();
for (Method method : methods) {
    if (method.getName().equals(methodName)) {
        firstParamType = getMethodFirstParamType(method);
return (firstParamType);
...
MethodgetMethodIfAny(final Object instance, final String name, final Class[] params)
get Method If Any
if (null != params && params.length > 0) {
    return getMethodIfAny(instance.getClass(), name, params);
} else {
    return getMethodIfAny(instance.getClass(), name);
MethodgetMethodIgnoreCaseWithNoParams(Object o, String p)
get Method Ignore Case With No Params
Class cls = o.getClass();
Method[] methods = cls.getMethods();
int point = 0;
Method r = null;
for (int i = 0; i < methods.length; i++) {
    Method m = methods[i];
    if (m.getName().equalsIgnoreCase(p) && m.getParameterTypes().length == 0) {
        return m;
...
TgetMethodInHolder(String methodName, Object holder)
get Method In Holder
return getMethodInHolder(methodName, holder, null);
ObjectgetMethodInstace(Class c, Object inst, String name, Class[] types, boolean access)
same as callMethod, but only returns a reference
if (c == null)
    c = inst.getClass();
try {
    Method method = null;
    while (method == null) {
        try {
            method = c.getDeclaredMethod(name, types);
        } catch (NoSuchMethodException e) {
...
StringgetMethodName(AccessibleObject method)
get Method Name
if (method instanceof Method) {
    return ((Method) method).getName();
} else if (method instanceof Constructor) {
    return ((Constructor) method).getName();
throw new IllegalArgumentException("Expected method or constructor");
MethodgetMethodNamed(String methodName, Object holder)
get Method Named
Method method = null;
List<Method> all = Arrays.asList(holder.getClass().getDeclaredMethods());
for (Method m : all) {
    if (methodName.equalsIgnoreCase(m.getName())) {
        method = m;
        break;
return method;
String[]getMethodNames(Object obj, boolean hasParent)
get Method Names
Method[] methods = getMethods(obj, hasParent);
int len = methods.length;
if (len < 1) {
    return null;
String[] names = new String[len];
for (int i = 0; i < len; i++) {
    Method m = methods[i];
...