Example usage for java.lang NoSuchMethodException NoSuchMethodException

List of usage examples for java.lang NoSuchMethodException NoSuchMethodException

Introduction

In this page you can find the example usage for java.lang NoSuchMethodException NoSuchMethodException.

Prototype

public NoSuchMethodException(String s) 

Source Link

Document

Constructs a NoSuchMethodException with a detail message.

Usage

From source file:org.apache.tomcat.util.IntrospectionUtils.java

public static Object callMethod0(Object target, String methodN) throws Exception {
    if (target == null) {
        d("Assert: Illegal params " + target);
        return null;
    }/*w  w  w.java 2s  .  c  om*/
    if (dbg > 0)
        d("callMethod0 " + target.getClass().getName() + "." + methodN);

    Class params[] = new Class[0];
    Method m = findMethod(target.getClass(), methodN, params);
    if (m == null)
        throw new NoSuchMethodException(target.getClass().getName() + " " + methodN);
    return m.invoke(target, emptyArray);
}

From source file:org.jgentleframework.utils.ReflectUtils.java

/**
 * Invokes the given <code>method</code> basing on the given
 * <code>target object</code>.
 * /*from ww w.  j a  v  a 2s.  c om*/
 * @param obj
 *            the target object
 * @param methodName
 *            the method name
 * @param paramTypes
 *            the parameter types array
 * @param args
 *            the arguments used for the method call
 * @param superBool
 *            nu l <b>true</b> s truy tm phng thc trn
 *            <code>Object Class</code> v c <code>SuperClass</code> ca
 *            <code>object</code> ch nh tng ng , ngc li nu l
 *            <b>false</b> s ch truy vn trn <code>Object Class</code>
 *            ch nh.
 * @param noThrows
 *            nu l <b>true</b> s khng nm ra <code>exception</code> nu
 *            nh gp li trong lc thi hnh, ngc li nu l <b>false</b>
 *            s nm ra ngoi l nu gp li trong lc thi hnh. Lu  rng
 *            tham s <code>noThrows</code> ch c hiu lc trn cc tin
 *            trnh <code>reflect</code> lc <code>invoke method</code>, nu
 *            bn thn <code>method</code> c <code>invoked</code> nm ra
 *            <code>exception</code> th c ch nh t?ng minh
 *            <code>noThrows</code> hay khng ?u khng c tc dng.
 * @return tr v? <code>Object</code> tr v? sau khi invoke method, nu
 *         <code>method</code> cn triu g?i khng <code>return</code> th
 *         kt qu tr v? s l <b>NULL</b>.
 * @throws NoSuchMethodException
 *             the no such method exception
 * @throws IllegalAccessException
 *             the illegal access exception
 * @throws InvocationTargetException
 *             the invocation target exception
 * @throws IllegalArgumentException
 */
public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramTypes, Object[] args,
        boolean superBool, boolean noThrows)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

    Class<?> clazz = null;
    if (ReflectUtils.isAnnotation(obj)) {
        clazz = ((Annotation) obj).annotationType();
    }
    clazz = obj.getClass();
    /*
     * Kim tra thng tin hp l ca parameters
     */
    if (paramTypes != null && args != null) {
        if (paramTypes.length != args.length) {
            throw new IllegalArgumentException("Parameter is invalid ! ");
        }
    }
    try {
        if (superBool == true) {
            Method method = ReflectUtils.getSupportedMethod(clazz, methodName, paramTypes);
            method.setAccessible(true);
            return method.invoke(obj, args);
        } else {
            return clazz.getDeclaredMethod(methodName, paramTypes).invoke(obj, args);
        }
    } catch (NoSuchMethodException ex) {
        if (noThrows == false) {
            throw new NoSuchMethodException(clazz.getName() + " does not support method " + methodName);
        }
    } catch (IllegalAccessException ex) {
        if (noThrows == false) {
            throw new IllegalAccessException(
                    "Insufficient access permissions to call" + methodName + " in class " + clazz.getName());
        }
    } catch (InvocationTargetException ex) {
        throw ex;
    }
    return null;
}

From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java

/** Loads strategy class and creates instance by calling constructor.
    @param strategyText contains full class name followed by
    parameter list for constructor.  Constructor parameters may be
    int, double, boolean, String.  Constructor parameters are parsed by
    splitting on commas and trimming whitespace.
    <pre>/*from w  w  w  .ja  v a 2 s  .c om*/
    mypkg.MyStrategy(12, -345.67, true, false, Alpha Strategy)
    </pre>
**/
protected TradingStrategy loadStrategy(String strategyText)
        throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
        ExceptionInInitializerError, InstantiationException, InvocationTargetException {
    Pattern strategyPattern = // matches full.class.Name(args...)
            Pattern.compile("^([A-Za-z](?:[A-Za-z0-9_.]*))\\s*[(](.*)[)]$");
    Matcher matcher = strategyPattern.matcher(strategyText);
    if (!matcher.matches())
        throw new IllegalArgumentException(
                "Bad Strategy: " + strategyText + "\n" + "Expected: full.class.name(-123.45, 67, true, false)");

    final String strategyClassName = matcher.group(1).trim();
    String parameters[] = matcher.group(2).split(",");

    // clean parameters
    for (int i = 0; i < parameters.length; i++)
        parameters[i] = parameters[i].trim();
    if (parameters.length == 1 && parameters[0].length() == 0)
        parameters = new String[] {}; // 0 parameters

    // build classpath
    String[] classPath = System.getProperty("java.class.path").split(File.pathSeparator);
    ArrayList<URL> classPathURLs = new ArrayList<URL>();
    for (int i = 0; i < classPath.length; i++) {
        String path = classPath[i];
        if (".".equals(path))
            path = System.getProperty("user.dir");
        path = path.replace(File.separatorChar, '/');
        if (!path.endsWith("/") && !path.endsWith(".jar"))
            path += "/";
        try {
            classPathURLs.add(new File(path).toURL());
        } catch (MalformedURLException e) {
            // bad directory in class path, skip
        }
    }
    final String strategyPackagePrefix = strategyClassName.substring(0,
            Math.max(0, strategyClassName.lastIndexOf('.') + 1));
    ClassLoader loader = new URLClassLoader(classPathURLs.toArray(new URL[] {}),
            this.getClass().getClassLoader()) {
        /** Don't search parent for classes with strategyPackagePrefix.
            Exception: interface TradingStrategy **/
        protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
            Class<?> loadedClass = findLoadedClass(className);
            if (loadedClass != null)
                return loadedClass;
            if (!className.startsWith(strategyPackagePrefix)
                    || className.equals(TradingStrategy.class.getName())) {
                loadedClass = this.getParent().loadClass(className);
                if (loadedClass != null)
                    return loadedClass;
            }
            loadedClass = findClass(className);
            if (loadedClass != null) {
                if (resolve)
                    resolveClass(loadedClass);
                return loadedClass;
            } else
                throw new ClassNotFoundException(className);
        }
    };
    // load class.  Throws ClassNotFoundException if not found.
    Class<?> strategyClass = loader.loadClass(strategyClassName);

    // Make sure it is a TradingStrategy.
    if (!TradingStrategy.class.isAssignableFrom(strategyClass))
        throw new ClassCastException(strategyClass.getName() + " does not implement TradingStrategy");

    // Find constructor compatible with parameters
    Constructor[] constructors = strategyClass.getConstructors();
    findConstructor: for (Constructor constructor : constructors) {
        Class<?>[] parameterTypes = constructor.getParameterTypes();
        if (parameterTypes.length != parameters.length)
            continue;
        Object[] values = new Object[parameterTypes.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            if (boolean.class.equals(parameterTypes[i])) {
                String parameter = parameters[i].toLowerCase();
                if ("false".equals(parameter))
                    values[i] = Boolean.FALSE;
                else if ("true".equals(parameter))
                    values[i] = Boolean.TRUE;
                else
                    continue findConstructor;
            } else if (int.class.equals(parameterTypes[i])) {
                try {
                    values[i] = new Integer(parameters[i]);
                } catch (NumberFormatException e) {
                    continue findConstructor;
                }
            } else if (double.class.equals(parameterTypes[i])) {
                try {
                    values[i] = new Double(parameters[i]);
                } catch (NumberFormatException e) {
                    continue findConstructor;
                }
            } else if (String.class.equals(parameterTypes[i])) {
                values[i] = parameters[i];
            } else
                continue findConstructor; // unsupported parameter type, skip
        }
        // all values matched types, so create instance
        return (TradingStrategy) constructor.newInstance(values);
    }
    throw new NoSuchMethodException(strategyText);
}

From source file:org.jabsorb.JSONRPCBridge.java

/**
 * Gets the methods that can be called on the given object
 *
 * @param objectID The id of the object or 0 if it is a class
 * @param className The name of the class of the object - only required if
 *          objectID==0//from   w w w .  j  a v  a2  s . c  o  m
 * @param methodName The name of method in the request
 * @return A map of AccessibleObjectKeys to a Collection of AccessibleObjects
 * @throws NoSuchMethodException If the method cannot be found in the class
 */
private Map getAccessibleObjectMap(final int objectID, final String className, final String methodName)
        throws NoSuchMethodException

{
    final Map methodMap = new HashMap();
    // if it is not an object
    if (objectID == 0) {
        final ObjectInstance oi = resolveObject(className);
        final ClassData classData = resolveClass(className);

        // Look up the class, object instance and method objects
        if (oi != null) {
            methodMap.putAll(ClassAnalyzer.getClassData(oi.getClazz()).getMethodMap());
        }
        // try to get the constructor data
        else if (methodName.equals(CONSTRUCTOR_FLAG)) {
            try {
                methodMap.putAll(ClassAnalyzer.getClassData(lookupClass(className)).getConstructorMap());
            } catch (Exception e) {
                throw new NoSuchMethodException(JSONRPCResult.MSG_ERR_NOCONSTRUCTOR);
            }
        }
        // else it must be static
        else if (classData != null) {
            methodMap.putAll(classData.getStaticMethodMap());
        } else {
            throw new NoSuchMethodException(JSONRPCResult.MSG_ERR_NOMETHOD);
        }
    }
    // else it is an object, so we can get the member methods
    else {
        final ObjectInstance oi = resolveObject(new Integer(objectID));
        if (oi == null) {
            throw new NoSuchMethodException();
        }
        ClassData cd = ClassAnalyzer.getClassData(oi.getClazz());
        methodMap.putAll(cd.getMethodMap());
    }
    return methodMap;
}

From source file:org.jspresso.framework.model.component.basic.AbstractComponentInvocationHandler.java

/**
 * Invokes a service method on the component.
 *
 * @param proxy/* w  w w. j ava  2  s  .  com*/
 *     the component to invoke the service on.
 * @param method
 *     the method implemented by the component.
 * @param args
 *     the arguments of the method implemented by the component.
 * @return the value returned by the method execution if any.
 *
 * @throws NoSuchMethodException
 *     if no mean could be found to service the method.
 */
@SuppressWarnings("unchecked")
protected Object invokeServiceMethod(Object proxy, Method method, Object... args) throws NoSuchMethodException {
    IComponentService service = componentDescriptor.getServiceDelegate(method);
    if (service != null) {
        try {
            if (service instanceof AbstractComponentServiceDelegate<?>) {
                Method refinedMethod = service.getClass().getMethod(method.getName(),
                        method.getParameterTypes());
                if (refinedMethod != null) {
                    return ((AbstractComponentServiceDelegate<Object>) service).executeWith(proxy,
                            refinedMethod, args);
                }
            }
            int signatureSize = method.getParameterTypes().length + 1;
            Class<?>[] parameterTypes = new Class<?>[signatureSize];
            Object[] parameters = new Object[signatureSize];

            parameterTypes[0] = componentDescriptor.getComponentContract();
            parameters[0] = proxy;

            for (int i = 1; i < signatureSize; i++) {
                parameterTypes[i] = method.getParameterTypes()[i - 1];
                parameters[i] = args[i - 1];
            }
            return MethodUtils.invokeMethod(service, method.getName(), parameters, parameterTypes);
        } catch (IllegalAccessException | NoSuchMethodException ex) {
            throw new ComponentException(ex);
        } catch (InvocationTargetException ex) {
            if (ex.getCause() instanceof RuntimeException) {
                throw (RuntimeException) ex.getCause();
            }
            throw new ComponentException(ex.getCause());
        }
    }
    throw new NoSuchMethodException(method.toString());
}

From source file:org.jabsorb.JSONRPCBridge.java

public static void main(String[] args) throws Exception {
    //String string="{\"id\":1,\"method\":\"test.echoList\",\"params\":[[1,2,3,4,5,6,7,8,9]]}";
    String string = "{\"id\":1,\"method\":\"test.echoList\",\"params\":[{\"a\":123,\"b\":456}]}";
    JSONObject jsonReq = new JSONObject(string);
    // #1: Parse the request
    final String encodedMethod;
    final Object requestId;
    final JSONArray arguments;
    final JSONArray fixups;

    encodedMethod = jsonReq.getString("method");
    arguments = jsonReq.getJSONArray("params");
    requestId = jsonReq.opt("id");
    fixups = jsonReq.optJSONArray("fixups");

    if (log.isDebugEnabled()) {
        if (fixups != null) {
            log.debug("call " + encodedMethod + "(" + arguments + ")" + ", requestId=" + requestId);
        } else {//w w  w.  j ava2s .c  o  m
            log.debug("call " + encodedMethod + "(" + arguments + ")" + ", fixups=" + fixups + ", requestId="
                    + requestId);
        }
    }

    // apply the fixups (if any) to the parameters. This will result
    // in a JSONArray that might have circular references-- so
    // the toString method (or anything that internally tries to traverse
    // the JSON (without being aware of this) should not be called after this
    // point

    if (fixups != null) {
        try {
            for (int i = 0; i < fixups.length(); i++) {
                JSONArray assignment = fixups.getJSONArray(i);
                JSONArray fixup = assignment.getJSONArray(0);
                JSONArray original = assignment.getJSONArray(1);
                //applyFixup(arguments, fixup, original);
            }
        } catch (JSONException e) {
            log.error("error applying fixups", e);
        }
    }

    // #2: Get the name of the class and method from the encodedMethod
    final String className;
    final String methodName;
    {
        StringTokenizer t = new StringTokenizer(encodedMethod, ".");
        if (t.hasMoreElements()) {
            className = t.nextToken();
        } else {
            className = null;
        }
        if (t.hasMoreElements()) {
            methodName = t.nextToken();
        } else {
            methodName = null;
        }
    }
    // #3: Get the id of the object (if it exists) from the className
    // (in the format: ".obj#<objectID>")
    final int objectID;
    {
        final int objectStartIndex = encodedMethod.indexOf('[');
        final int objectEndIndex = encodedMethod.indexOf(']');
        if (encodedMethod.startsWith(OBJECT_METHOD_PREFIX) && (objectStartIndex != -1) && (objectEndIndex != -1)
                && (objectStartIndex < objectEndIndex)) {
            objectID = Integer.parseInt(encodedMethod.substring(objectStartIndex + 1, objectEndIndex));
        } else {
            objectID = 0;
        }
    }
    JSONRPCBridge bridge = new JSONRPCBridge();
    bridge.registerObject("test", new Test());
    // #5: Get the object to act upon and the possible method that could be
    // called on it
    final Map methodMap;
    final Object javascriptObject;
    AccessibleObject accessibleObject = null;
    try {
        javascriptObject = bridge.getObjectContext(objectID, className);
        methodMap = bridge.getAccessibleObjectMap(objectID, className, methodName);
        // #6: Resolve the method
        accessibleObject = AccessibleObjectResolver.resolveMethod(methodMap, methodName, arguments, ser);
        if (accessibleObject == null) {
            throw new NoSuchMethodException(JSONRPCResult.MSG_ERR_NOMETHOD);
        }
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    final Class[] parameterTypes;
    final boolean isConstructor = accessibleObject instanceof Constructor;
    if (isConstructor) {
        parameterTypes = ((Constructor) accessibleObject).getParameterTypes();
    } else {
        parameterTypes = ((Method) accessibleObject).getParameterTypes();
    }

    // Unmarshall arguments
    final Object javaArgs[] = unmarshallArgs(parameterTypes, arguments, ser);
}

From source file:org.wandora.modules.ModuleManager.java

/**
 * Parses a single param element and returns its value. Handles all the
 * different cases of how a param elements value can be determined.
 * /*  w w  w  . j  av a  2  s . c o  m*/
 * @param e The xml param element.
 * @return The value of the parameter.
 */
public Object parseXMLParamElement(Element e)
        throws ReflectiveOperationException, IllegalArgumentException, ScriptException {
    String instance = e.getAttribute("instance");
    if (instance != null && instance.length() > 0) {
        Class cls = Class.forName(instance);
        HashMap<String, Object> params = parseXMLOptionsElement(e);
        if (!params.isEmpty()) {
            Collection<Object> constructorParams = params.values();
            Constructor[] cs = cls.getConstructors();
            ConstructorLoop: for (int i = 0; i < cs.length; i++) {
                Constructor c = cs[i];
                Class[] paramTypes = c.getParameterTypes();
                if (paramTypes.length != constructorParams.size())
                    continue;

                int j = -1;
                for (Object o : constructorParams) {
                    j++;
                    if (o == null) {
                        if (!paramTypes[j].isPrimitive())
                            continue;
                        else
                            continue ConstructorLoop;
                    }

                    if (paramTypes[j].isPrimitive()) {
                        if (paramTypes[j] == int.class) {
                            if (o.getClass() != Integer.class)
                                continue ConstructorLoop;
                        } else if (paramTypes[j] == long.class) {
                            if (o.getClass() != Long.class)
                                continue ConstructorLoop;
                        } else if (paramTypes[j] == double.class) {
                            if (o.getClass() != Double.class)
                                continue ConstructorLoop;
                        } else if (paramTypes[j] == float.class) {
                            if (o.getClass() != Float.class)
                                continue ConstructorLoop;
                        } else if (paramTypes[j] == byte.class) {
                            if (o.getClass() != Byte.class)
                                continue ConstructorLoop;
                        } else
                            continue ConstructorLoop; //did we forget some primitive type?
                    } else if (!o.getClass().isAssignableFrom(paramTypes[j]))
                        continue ConstructorLoop;
                }

                return c.newInstance(constructorParams.toArray());
            }
            throw new NoSuchMethodException(
                    "Couldn't find a constructor that matches parameters parsed from XML.");
        } else {
            return cls.newInstance();
        }
    }

    String clas = e.getAttribute("class");
    if (clas != null && clas.length() > 0) {
        Class cls = Class.forName(clas);
        return cls;
    }

    if (e.hasAttribute("null"))
        return null;

    if (e.hasAttribute("script")) {
        String engine = e.getAttribute("script");
        if (engine.length() == 0 || engine.equalsIgnoreCase("default"))
            engine = ScriptManager.getDefaultScriptEngine();
        ScriptManager scriptManager = new ScriptManager();
        ScriptEngine scriptEngine = scriptManager.getScriptEngine(engine);
        scriptEngine.put("moduleManager", this);
        scriptEngine.put("element", e);

        try {
            String script = ((String) xpath.evaluate("text()", e, XPathConstants.STRING)).trim();
            return scriptManager.executeScript(script, scriptEngine);
        } catch (XPathExpressionException xpee) {
            throw new RuntimeException(xpee);
        }
    }

    if (e.hasAttribute("module")) {
        String moduleName = e.getAttribute("module").trim();
        return new ModuleDelegate(this, moduleName);
    }

    try {
        String value = ((String) xpath.evaluate("text()", e, XPathConstants.STRING)).trim();
        return replaceVariables(value, variables);
    } catch (XPathExpressionException xpee) {
        throw new RuntimeException(xpee);
    }
}

From source file:objenome.util.ClassUtils.java

/**
 * <p>Returns the desired Method much like {@code Class.getMethod}, however
 * it ensures that the returned Method is from a public class or interface and not
 * from an anonymous inner class. This means that the Method is invokable and
 * doesn't fall foul of Java bug/* w w w  .j ava 2 s .c  om*/
 * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957">4071957</a>).</p>
 *
 *  <pre>
 *  <code>Set set = Collections.unmodifiableSet(...);
 *  Method method = ClassUtils.getPublicMethod(set.getClass(), "isEmpty",  new Class[0]);
 *  Object result = method.invoke(set, new Object[]);</code>
 *  </pre>
 *
 * @param cls  the class to check, not null
 * @param methodName  the name of the method
 * @param parameterTypes  the list of parameters
 * @return the method
 * @throws NullPointerException if the class is null
 * @throws SecurityException if a security violation occurred
 * @throws NoSuchMethodException if the method is not found in the given class
 *  or if the method doesn't conform with the requirements
 */
public static Method getPublicMethod(Class<?> cls, String methodName, Class<?>... parameterTypes)
        throws SecurityException, NoSuchMethodException {

    Method declaredMethod = cls.getMethod(methodName, parameterTypes);
    if (Modifier.isPublic(declaredMethod.getDeclaringClass().getModifiers())) {
        return declaredMethod;
    }

    List<Class<?>> candidateClasses = new ArrayList<>(getAllInterfaces(cls));
    candidateClasses.addAll(getAllSuperclasses(cls));

    for (Class<?> candidateClass : candidateClasses) {
        if (!Modifier.isPublic(candidateClass.getModifiers())) {
            continue;
        }
        Method candidateMethod;
        try {
            candidateMethod = candidateClass.getMethod(methodName, parameterTypes);
        } catch (NoSuchMethodException ex) {
            continue;
        }
        if (Modifier.isPublic(candidateMethod.getDeclaringClass().getModifiers())) {
            return candidateMethod;
        }
    }

    throw new NoSuchMethodException(
            "Can't find a public method for " + methodName + ' ' + ArrayUtils.toString(parameterTypes));
}

From source file:org.enerj.apache.commons.beanutils.PropertyUtilsBean.java

/**
 * Return the value of the specified simple property of the specified
 * bean, with no type conversions./*from ww w  . j  a  v a2  s. c o  m*/
 *
 * @param bean Bean whose property is to be extracted
 * @param name Name of the property to be extracted
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception IllegalArgumentException if <code>bean</code> or
 *  <code>name</code> is null
 * @exception IllegalArgumentException if the property name
 *  is nested or indexed
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 * @exception NoSuchMethodException if an accessor method for this
 *  propety cannot be found
 */
public Object getSimpleProperty(Object bean, String name)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified");
    }

    // Validate the syntax of the property name
    if (name.indexOf(PropertyUtils.NESTED_DELIM) >= 0) {
        throw new IllegalArgumentException("Nested property names are not allowed");
    } else if (name.indexOf(PropertyUtils.INDEXED_DELIM) >= 0) {
        throw new IllegalArgumentException("Indexed property names are not allowed");
    } else if (name.indexOf(PropertyUtils.MAPPED_DELIM) >= 0) {
        throw new IllegalArgumentException("Mapped property names are not allowed");
    }

    // Handle DynaBean instances specially
    if (bean instanceof DynaBean) {
        DynaProperty descriptor = ((DynaBean) bean).getDynaClass().getDynaProperty(name);
        if (descriptor == null) {
            throw new NoSuchMethodException("Unknown property '" + name + "'");
        }
        return (((DynaBean) bean).get(name));
    }

    // Retrieve the property getter method for the specified property
    PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException("Unknown property '" + name + "'");
    }
    Method readMethod = getReadMethod(descriptor);
    if (readMethod == null) {
        throw new NoSuchMethodException("Property '" + name + "' has no getter method");
    }

    // Call the property getter and return the value
    Object value = invokeMethod(readMethod, bean, new Object[0]);
    return (value);

}

From source file:com.p5solutions.core.jpa.orm.EntityUtility.java

/**
 * Builds a single {@link ParameterBinder} for a given entity class method.
 * For example get methods that have been annotated with {@link Column} or
 * {@link JoinColumn} or {@link JoinColumns}
 * /*from   w w w  .  j  av  a  2  s  .c om*/
 * @param <T>
 *          the generic type of the entity class in question.
 * @param entityClass
 *          the entity class as specified
 * @param getterMethod
 *          the getter method of the parameter
 * @param setterMethod
 *          the supporting setter method of the getter method of the parameter
 * @param index
 *          the index of the parameter being processed
 * @param recursionFilterList
 *          the recursion filter list, a restriction filter, such that
 *          dependency graphs don't go into a recursive loop.
 * @return the {@link ParameterBinder} that was built for the given
 *         getter/setter and entity.
 */
public <T> ParameterBinder buildParameterBinder(Class<T> entityClass, String bindingPath, Method getterMethod,
        Method setterMethod, Method parentGetterMethod, Method parentSetterMethod, int index,
        List<Class<?>> recursionFilterList) {

    ParameterBinder binder = new ParameterBinder();

    // set the binding path if any. note this might be part of a recursive call
    // usually a join-column or embedded object
    String fieldName = ReflectionUtility.buildFieldName(getterMethod);
    if (parentGetterMethod != null) {
        binder.setBindingPath(bindingPath + "." + fieldName);
    } else {
        binder.setBindingPath(fieldName);
    }

    // build the binding name
    String bindingName = formatBindingName(ReflectionUtility.buildFieldName(getterMethod));
    binder.setBindingIndex(index);
    binder.setBindingName(bindingName);
    binder.setGetterMethod(getterMethod);
    binder.setSetterMethod(setterMethod);
    binder.setEntityClass(entityClass);

    if (doColumn(binder, recursionFilterList)) {
        // TODO ??
    } else if (doJoinColumn(binder, recursionFilterList)) {
        // TODO ??

        //if (entityClass.equals(binder.getEntityClass())) {

        //}
    }

    /*
     * for (int j = 0; j < annotations.length; j++) { Annotation annotation =
     * annotations[j]; if (annotation instanceof Column) { Column column =
     * (Column) annotation; } // TODO check for max, min lengths!! else if
     * (annotation instanceof Id) { // Id id = (Id) annotation;
     * binder.setPrimaryKey(true); // } else if (annotation instanceof
     * SequenceGenerator) { // SequenceGenerator sequenceGenerator = //
     * (SequenceGenerator)annotation; } else if (annotation instanceof
     * Transient) { binder.setTransient(true); } }
     */

    // check for setter method if not transient get method
    if (!binder.isTransient()) {
        if (binder.getSetterMethod() == null) {
            String error = "No set method for corresponding get method " + getterMethod.getName()
                    + " found in entity class type " + entityClass;
            logger.error(error);
            throw new RuntimeException(new NoSuchMethodException(error));
        }
    }

    return binder;
}