1 19 20 package edu.umd.cs.findbugs.filter; 21 22 23 import edu.umd.cs.findbugs.BugInstance; 24 import edu.umd.cs.findbugs.MethodAnnotation; 25 26 public class MethodMatcher implements Matcher { 27 private NameMatch name; 28 private String signature; 29 30 public MethodMatcher(String name) { 31 this.name = new NameMatch(name); 32 } 33 34 public MethodMatcher(String name, String params, String returns) { 35 this.name = new NameMatch(name); 36 this.signature = SignatureUtil.createMethodSignature(params, returns); 37 } 38 39 public boolean match(BugInstance bugInstance) { 40 MethodAnnotation methodAnnotation = bugInstance.getPrimaryMethod(); 41 if (methodAnnotation == null) 42 return false; 43 if (!name.match(methodAnnotation.getMethodName())) 44 return false; 45 if (signature != null && !signature.equals(methodAnnotation.getMethodSignature())) 46 return false; 47 return true; 48 } 49 } 50 51 | Popular Tags |