Example usage for org.apache.commons.lang.reflect MethodUtils getAccessibleMethod

List of usage examples for org.apache.commons.lang.reflect MethodUtils getAccessibleMethod

Introduction

In this page you can find the example usage for org.apache.commons.lang.reflect MethodUtils getAccessibleMethod.

Prototype

public static Method getAccessibleMethod(Class cls, String methodName, Class[] parameterTypes) 

Source Link

Document

Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters.

Usage

From source file:com.haulmont.cuba.gui.xml.DeclarativeColumnGenerator.java

protected Method findGeneratorMethod(Class cls, String methodName) {
    Method exactMethod = MethodUtils.getAccessibleMethod(cls, methodName, Entity.class);
    if (exactMethod != null) {
        return exactMethod;
    }/* w  ww  . ja va  2s .  c  om*/

    // search through all methods
    Method[] methods = cls.getMethods();
    for (Method availableMethod : methods) {
        if (availableMethod.getName().equals(methodName)) {
            if (availableMethod.getParameterCount() == 1
                    && Component.class.isAssignableFrom(availableMethod.getReturnType())) {
                if (Entity.class.isAssignableFrom(availableMethod.getParameterTypes()[0])) {
                    // get accessible version of method
                    return MethodUtils.getAccessibleMethod(availableMethod);
                }
            }
        }
    }
    return null;
}

From source file:com.haulmont.cuba.gui.components.FieldGroupTest.java

protected Object getComposition(FieldGroup.FieldConfig fc) {
    Method getCompositionMethod = MethodUtils.getAccessibleMethod(fc.getClass(), "getComposition",
            new Class[] {});
    Object composition;/*  ww w  .j  a  v a2s  . c  om*/
    try {
        composition = getCompositionMethod.invoke(fc);
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException("Invoke error", e);
    }
    return composition;
}

From source file:gobblin.hive.metastore.HiveMetaStoreUtils.java

@VisibleForTesting
protected static void inVokeDetermineSchemaOrThrowExceptionMethod(Properties props, Configuration conf)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    String methodName = "determineSchemaOrThrowException";
    Method method = MethodUtils.getAccessibleMethod(AvroSerdeUtils.class, methodName, Properties.class);
    boolean withConf = false;
    if (method == null) {
        method = MethodUtils.getAccessibleMethod(AvroSerdeUtils.class, methodName,
                new Class[] { Configuration.class, Properties.class });
        withConf = true;//from   ww  w  . java2 s  .  c  om
    }
    Preconditions.checkNotNull(method, "Cannot find matching " + methodName);
    if (!withConf) {
        MethodUtils.invokeStaticMethod(AvroSerdeUtils.class, methodName, props);
    } else {
        MethodUtils.invokeStaticMethod(AvroSerdeUtils.class, methodName, new Object[] { conf, props });
    }
}

From source file:org.nekorp.workflow.desktop.view.resource.imp.CostoServicioTableModel.java

@Override
public Class<?> getColumnClass(int columnIndex) {
    Class<?> r = MethodUtils
            .getAccessibleMethod(RegistroCostoVB.class, metodosGet.get(columnIndex), new Class[] {})
            .getReturnType();//from www.j  a v a  2 s.  c o m
    if (r.isPrimitive() && r.getName().equals("boolean")) {
        return Boolean.class;
    }
    return r;
}