public int getTypeDifferenceWeight(Class<?>[] paramTypes) { // If valid arguments found, determine type difference weight. // Try type difference weight on both the converted arguments and // the raw arguments. If the raw weight is better, use it. // Decrease raw weight by 1024 to prefer it over equal converted weight. int typeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.arguments); int rawTypeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.rawArguments) - 1024; return (rawTypeDiffWeight < typeDiffWeight ? rawTypeDiffWeight : typeDiffWeight); }
public int getTypeDifferenceWeight(Class<?>[] paramTypes) { // If valid arguments found, determine type difference weight. // Try type difference weight on both the converted arguments and // the raw arguments. If the raw weight is better, use it. // Decrease raw weight by 1024 to prefer it over equal converted weight. int typeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.arguments); int rawTypeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.rawArguments) - 1024; return (rawTypeDiffWeight < typeDiffWeight ? rawTypeDiffWeight : typeDiffWeight); }
Class<?>[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) { int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight;
Class<?>[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) { int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight;
public int getTypeDifferenceWeight(Class[] paramTypes) { // If valid arguments found, determine type difference weight. // Try type difference weight on both the converted arguments and // the raw arguments. If the raw weight is better, use it. // Decrease raw weight by 1024 to prefer it over equal converted weight. int typeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.arguments); int rawTypeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.rawArguments) - 1024; return (rawTypeDiffWeight < typeDiffWeight ? rawTypeDiffWeight : typeDiffWeight); }
/** * Find a matching method with the specified name for the specified arguments. * @return a matching method, or <code>null</code> if none * @see #getTargetClass() * @see #getTargetMethod() * @see #getArguments() */ protected Method findMatchingMethod() { String targetMethod = getTargetMethod(); Object[] arguments = getArguments(); int argCount = arguments.length; Method[] candidates = ReflectionUtils.getAllDeclaredMethods(getTargetClass()); int minTypeDiffWeight = Integer.MAX_VALUE; Method matchingMethod = null; for (Method candidate : candidates) { if (candidate.getName().equals(targetMethod)) { Class[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) { int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight; matchingMethod = candidate; } } } } return matchingMethod; }
Class<?>[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) { int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight;
Class<?>[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) { int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments); if (typeDiffWeight < minTypeDiffWeight) { minTypeDiffWeight = typeDiffWeight;