• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ClassBoundCriterion implements Criterion {
9 
10   private final String className;
11   public final BoundLocation boundLoc;
12   private final Criterion notInMethodCriterion;
13   private final Criterion boundLocCriterion;
14 
ClassBoundCriterion(String className, BoundLocation boundLoc)15   public ClassBoundCriterion(String className, BoundLocation boundLoc) {
16     this.className = className;
17     this.boundLoc = boundLoc;
18     this.notInMethodCriterion = Criteria.notInMethod();
19     this.boundLocCriterion = 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     if (path == null) {
33       return false;
34     }
35 
36     return boundLocCriterion.isSatisfiedBy(path) &&
37       notInMethodCriterion.isSatisfiedBy(path);
38   }
39 
40   @Override
getKind()41   public Kind getKind() {
42     return Kind.CLASS_BOUND;
43   }
44 
45   @Override
toString()46   public String toString() {
47     return "ClassBoundCriterion: for " + className + " at " + boundLoc;
48   }
49 }
50