@Test public void mustFindMethodsWithStringParameters() { List<MethodNode> methodNodes = findMethodsWithParameter(classNode.methods, Type.getType(String.class)); assertEquals(1, methodNodes.size()); assertEquals("method2", methodNodes.get(0).name); }
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; }
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; } }
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(); }
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); }
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);  }