SearchUtils { public static List<MethodNode> findMethodsWithParameter(Collection<MethodNode> methodNodes, Type expectedParamType) { Validate.notNull(methodNodes); Validate.notNull(expectedParamType); Validate.noNullElements(methodNodes); Validate.isTrue(expectedParamType.getSort() != Type.METHOD && expectedParamType.getSort() != Type.VOID); List<MethodNode> ret = new ArrayList<>(); for (MethodNode methodNode : methodNodes) { Type methodDescType = Type.getType(methodNode.desc); Type[] methodParamTypes = methodDescType.getArgumentTypes(); if (Arrays.asList(methodParamTypes).contains(expectedParamType)) { ret.add(methodNode); } } return ret; } private  SearchUtils(); static List<MethodNode> findMethodsWithName(Collection<MethodNode> methodNodes, String name); static List<MethodNode> findStaticMethods(Collection<MethodNode> methodNodes); static List<MethodNode> findMethodsWithParameter(Collection<MethodNode> methodNodes, Type expectedParamType); static List<MethodNode> findMethodsWithParameters(Collection<MethodNode> methodNodes, Type ... paramTypes); static MethodNode findMethod(Collection<MethodNode> methodNodes, boolean isStatic, Type returnType, String name,
            Type ... paramTypes); static List<AbstractInsnNode> findInvocationsOf(InsnList insnList, Method expectedMethod); static List<AbstractInsnNode> findInvocationsWithParameter(InsnList insnList,
            Type expectedParamType); static List<AbstractInsnNode> searchForOpcodes(InsnList insnList, int ... opcodes); static List<TryCatchBlockNode> findTryCatchBlockNodesEncompassingInstruction(InsnList insnList,
            List<TryCatchBlockNode> tryCatchBlockNodes, AbstractInsnNode insnNode); static LineNumberNode findLineNumberForInstruction(InsnList insnList, AbstractInsnNode insnNode); static LocalVariableNode findLocalVariableNodeForInstruction(List<LocalVariableNode> lvnList, InsnList insnList,
            final AbstractInsnNode insnNode, int idx); static FieldNode findField(ClassNode classNode, String name);  }
@Test public void mustFindMethodsWithIntParameters() { List<MethodNode> methodNodes = findMethodsWithParameter(classNode.methods, Type.INT_TYPE); assertEquals(2, methodNodes.size()); assertEquals("method1", methodNodes.get(0).name); assertEquals("method2", methodNodes.get(1).name); }
@Test public void mustFindMethodsWithStringParameters() { List<MethodNode> methodNodes = findMethodsWithParameter(classNode.methods, Type.getType(String.class)); assertEquals(1, methodNodes.size()); assertEquals("method2", methodNodes.get(0).name); }