@Override public void with(Method method) { if (method == null) { throw new IllegalArgumentException("A metod cannot be replaced with null."); } if (!Modifier.isStatic(this.method.getModifiers())) { throw new IllegalArgumentException(String.format("Replace requires static methods, '%s' is not static", this.method)); } else if (!Modifier.isStatic(method.getModifiers())) { throw new IllegalArgumentException(String.format("Replace requires static methods, '%s' is not static", method)); } else if(!this.method.getReturnType().isAssignableFrom(method.getReturnType())) { throw new IllegalArgumentException(String.format("The replacing method (%s) needs to return %s and not %s.",method.toString(), this.method.getReturnType().getName(), method.getReturnType().getName())); } else if(!WhiteboxImpl.checkIfParameterTypesAreSame(this.method.isVarArgs(),this.method.getParameterTypes(), method.getParameterTypes())) { throw new IllegalArgumentException(String.format("The replacing method, \"%s\", needs to have the same number of parameters of the same type as as method \"%s\".",method.toString(),this.method.toString())); } else { MethodProxy.proxy(this.method, new MethodInvocationHandler(method)); } }
&& checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, method.getParameterTypes())) { method.setAccessible(true); return method;
for (Method method : methods) { final Class<?>[] parameterTypes = method.getParameterTypes(); if (checkIfParameterTypesAreSame(method.isVarArgs(), expectedTypes, parameterTypes) || (!exactParameterTypeMatch && checkIfParameterTypesAreSame(method.isVarArgs(), convertParameterTypesToPrimitive(expectedTypes), parameterTypes))) { matchingArgumentTypes.add(method);
&& checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, method.getParameterTypes())) { method.setAccessible(true); return method;
if (!checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, paramTypes)) { continue;
for (Method method : methods) { final Class<?>[] parameterTypes = method.getParameterTypes(); if (checkIfParameterTypesAreSame(method.isVarArgs(), expectedTypes, parameterTypes) || (!exactParameterTypeMatch && checkIfParameterTypesAreSame(method.isVarArgs(), convertParameterTypesToPrimitive(expectedTypes), parameterTypes))) { matchingArgumentTypes.add(method);
if (!checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, paramTypes)) { continue;
if (checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, method.getParameterTypes())) { foundMethods.add(method); if (foundMethods.size() == 1) {
if (checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, method.getParameterTypes())) { foundMethods.add(method); if (foundMethods.size() == 1) {
if (!checkIfParameterTypesAreSame(constructor.isVarArgs(), convertArgumentTypesToPrimitive(paramTypes, arguments), paramTypes)) { primitiveConstructorFound = false;
if (!checkIfParameterTypesAreSame(method.isVarArgs(), convertArgumentTypesToPrimitive(paramTypes, arguments), paramTypes)) { primitiveMethodFound = false;