11package pattern .atomic ;
22
3- import analysis .data .PatternMatch ;
43import diff .difftree .DiffNode ;
54import diff .difftree .DiffTree ;
65import diff .difftree .DiffType ;
76import pattern .EditPattern ;
87
9- import java .util .Optional ;
10-
118public abstract class AtomicPattern extends EditPattern <DiffNode > {
129 private final DiffType diffType ;
1310
@@ -29,35 +26,14 @@ public DiffType getDiffType() {
2926 */
3027 protected abstract boolean matchesCodeNode (DiffNode codeNode );
3128
32- /**
33- * Creates a PatternMatch object for the given codeNode.
34- * Assumes {@code matches(codeNode) == true}.
35- * @param codeNode A node that was matched to this pattern.
36- * @return A PatternMatch object containing metadata when matching this pattern to the given node.
37- */
38- protected abstract PatternMatch <DiffNode > createMatchOnCodeNode (DiffNode codeNode );
39-
4029 /**
4130 * @return True if this pattern matches the given node and node is code.
4231 */
32+ @ Override
4333 public final boolean matches (DiffNode node ) {
4434 return node .isCode () && node .diffType == diffType && matchesCodeNode (node );
4535 }
4636
47- /**
48- * Matches this pattern onto the given node.
49- * @param x The node to match this pattern on.
50- * @return A {@link PatternMatch<DiffNode>} if the given node matches this pattern (i.e., {@code matches(x) == true}). Empty otherwise.
51- */
52- @ Override
53- public final Optional <PatternMatch <DiffNode >> match (DiffNode x ) {
54- if (matches (x )) {
55- return Optional .of (createMatchOnCodeNode (x ));
56- }
57-
58- return Optional .empty ();
59- }
60-
6137 public boolean anyMatch (final DiffTree t ) {
6238 return t .anyMatch (this ::matches );
6339 }
0 commit comments