1 package annotator.find; 2 3 import annotations.el.BoundLocation; 4 5 import com.sun.source.util.TreePath; 6 import com.sun.source.tree.Tree; 7 8 public class MethodBoundCriterion implements Criterion { 9 10 private final String methodName; 11 public final BoundLocation boundLoc; 12 private final Criterion sigMethodCriterion; 13 private final Criterion boundLocationCriterion; 14 MethodBoundCriterion(String methodName, BoundLocation boundLoc)15 public MethodBoundCriterion(String methodName, BoundLocation boundLoc) { 16 this.methodName = methodName; 17 this.boundLoc = boundLoc; 18 this.sigMethodCriterion = Criteria.inMethod(methodName); 19 this.boundLocationCriterion = Criteria.atBoundLocation(boundLoc); 20 } 21 22 /** {@inheritDoc} */ 23 @Override isSatisfiedBy(TreePath path, Tree leaf)24 public boolean isSatisfiedBy(TreePath path, Tree leaf) { 25 assert path == null || path.getLeaf() == leaf; 26 return isSatisfiedBy(path); 27 } 28 29 /** {@inheritDoc} */ 30 @Override isSatisfiedBy(TreePath path)31 public boolean isSatisfiedBy(TreePath path) { 32 return sigMethodCriterion.isSatisfiedBy(path) && 33 boundLocationCriterion.isSatisfiedBy(path); 34 } 35 36 @Override getKind()37 public Kind getKind() { 38 return Kind.METHOD_BOUND; 39 } 40 41 @Override toString()42 public String toString() { 43 return "MethodBoundCriterion: method: " + methodName + " bound boundLoc: " + boundLoc; 44 } 45 } 46