Example usage for java.lang.reflect Method getName

List of usage examples for java.lang.reflect Method getName

Introduction

In this page you can find the example usage for java.lang.reflect Method getName.

Prototype

@Override
public String getName() 

Source Link

Document

Returns the name of the method represented by this Method object, as a String .

Usage

From source file:org.psnively.scala.beans.ScalaBeanInfo.java

public static boolean isScalaSetter(Method method) {
    return method.getParameterTypes().length == 1 && method.getReturnType().equals(Void.TYPE)
            && method.getName().endsWith(SCALA_SETTER_SUFFIX);
}

From source file:pl.bristleback.server.bristle.conf.resolver.action.ActionResolvingUtils.java

public static String resolveClientActionName(Method actionMethod, boolean validate) {
    ClientAction actionAnnotation = AnnotationUtils.findAnnotation(actionMethod, ClientAction.class);
    if (actionAnnotation == null || StringUtils.isBlank(actionAnnotation.value())) {
        return actionMethod.getName();
    }//from w  w  w.  j  av a2  s  .com
    if (validate) {
        validateActionNameFromAnnotationValue(actionAnnotation.value());
    }
    return actionAnnotation.value();
}

From source file:org.psnively.scala.beans.ScalaBeanInfo.java

private static boolean isScalaGetter(Method method) {
    return method.getParameterTypes().length == 0 && !method.getReturnType().equals(Void.TYPE)
            && !(method.getName().startsWith("get") || method.getName().startsWith("is"));
}

From source file:com.netflix.paas.config.base.ConfigurationProxyUtils.java

static String getPropertyName(Method method, Configuration c) {
    String name = c.value();/*  w w w .ja v  a  2s  .  c om*/
    if (name.isEmpty()) {
        name = method.getName();
        name = StringUtils.removeStart(name, "is");
        name = StringUtils.removeStart(name, "get");
        name = name.toLowerCase();
    }
    return name;
}

From source file:de.micromata.genome.gwiki.page.impl.actionbean.ActionBeanUtils.java

private static Method findMethod(ActionBean bean, String methodName) {
    for (Method m : bean.getClass().getMethods()) {
        if (m.getName().equals(methodName) == true) {
            return m;
        }//from ww w. j a  v a2s. c  o  m
    }
    return null;

}

From source file:com.github.cherimojava.data.mongo.entity.EntityUtils.java

/**
 * returns the getter method matching the given Adder method or throws an exception if no such method exists
 *
 * @param m adder method for which the matching getter method shall be found
 * @return getter method belonging to the given Adder method
 * @throws java.lang.IllegalArgumentException if the given Adder method has no corresponding getter method
 *//*from w  ww . ja  v a2s.co m*/
static Method getGetterFromAdder(Method m) {
    try {
        return m.getDeclaringClass().getMethod(m.getName().replaceFirst("add", "get"));
    } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException(format("Method %s has no corresponding getter method", m.getName()));
    }
}

From source file:net.sourceforge.stripes.integration.spring.SpringHelper.java

/**
 * A slightly unusual, and somewhat "loose" conversion of a method name to a property
 * name. Assumes that the name is in fact a mutator for a property and will do the
 * usual {@code setFoo} to {@code foo} conversion if the method follows the normal
 * syntax, otherwise will just return the method name.
 *
 * @param m the method to determine the property name of
 * @return a String property name/*w  w w.  j  a  va2s. c o  m*/
 */
protected static String methodToPropertyName(Method m) {
    String name = m.getName();
    if (name.startsWith("set") && name.length() > 3) {
        String ret = name.substring(3, 4).toLowerCase();
        if (name.length() > 4)
            ret += name.substring(4);
        return ret;
    } else {
        return name;
    }
}

From source file:de.micromata.genome.tpsb.GroovyExceptionInterceptor.java

protected static String renderMethodBlock(Map<String, Method> collectedMethods) {
    StringBuilder sb = new StringBuilder();
    for (String methn : collectedMethods.keySet()) {

        Method m = collectedMethods.get(methn);

        sb.append("  ").append(methn).append("{\n")//
                .append("    return wrappExpectedEx( { target.").append(m.getName()).append("(");
        for (int i = 0; i < m.getParameterTypes().length; ++i) {
            if (i > 0) {
                sb.append(", ");
            }/*from   w ww. j av a2s.  co  m*/
            sb.append("arg").append(i);
        }
        sb.append(");");
        sb.append("} );\n  }\n");
    }
    return sb.toString();
}

From source file:Main.java

private static Method findNeededMethod(String methodName, Class<?>[] cs, Method[] methods) {

    if (methodName == null || "".equals(methodName.trim()) || methods == null || methods.length == 0)
        return null;

    out: for (Method m : methods) {
        Class<?>[] clzs = m.getParameterTypes();

        if (cs.length != clzs.length)
            continue;

        for (int i = 0; i < cs.length; i++)
            if (cs[i] != clzs[i])
                continue out;

        if (methodName.equals(m.getName()))
            return m;
    }//from w  ww  .ja va  2 s  .co  m
    return null;
}

From source file:org.openflamingo.uploader.el.ELService.java

public static Method findMethod(String className, String methodName) throws SystemException {
    Method method = null;/*from ww w.  j  a  v a  2 s .c om*/
    try {
        Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
        for (Method m : clazz.getMethods()) {
            if (m.getName().equals(methodName)) {
                method = m;
                break;
            }
        }
        if (method == null) {
            // throw new SystemException(ErrorCode.E0111, className, methodName);
        }
        if ((method.getModifiers() & (Modifier.PUBLIC | Modifier.STATIC)) != (Modifier.PUBLIC
                | Modifier.STATIC)) {
            // throw new SystemException(ErrorCode.E0112, className, methodName);
        }
    } catch (ClassNotFoundException ex) {
        // throw new SystemException(ErrorCode.E0113, className);
    }
    return method;
}