Search in sources :

Example 1 with JSSetter

use of org.mozilla.javascript.annotations.JSSetter in project hackpad by dropbox.

the class ScriptableObject method findSetterMethod.

private static Method findSetterMethod(Method[] methods, String name, String prefix) {
    String newStyleName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
    for (Method method : methods) {
        JSSetter annotation = method.getAnnotation(JSSetter.class);
        if (annotation != null) {
            if (name.equals(annotation.value()) || ("".equals(annotation.value()) && newStyleName.equals(method.getName()))) {
                return method;
            }
        }
    }
    String oldStyleName = prefix + name;
    for (Method method : methods) {
        if (oldStyleName.equals(method.getName())) {
            return method;
        }
    }
    return null;
}
Also used : Method(java.lang.reflect.Method) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Aggregations

Method (java.lang.reflect.Method)1 JSSetter (org.mozilla.javascript.annotations.JSSetter)1