-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEditClass.java
More file actions
51 lines (44 loc) · 1.66 KB
/
EditClass.java
File metadata and controls
51 lines (44 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.variantsync.diffdetective.editclass;
import org.variantsync.diffdetective.variation.diff.DiffNode;
import org.variantsync.diffdetective.variation.diff.VariationDiff;
import org.variantsync.diffdetective.variation.diff.DiffType;
/**
* Abstract edit class according to our ESEC/FSE'22 paper.
* @author Paul Bittner, Sören Viegener
*/
public abstract class EditClass extends Pattern<DiffNode<?>> {
private final DiffType diffType;
/**
* Each edit class handles exactly one DiffType.
* @param name unique identifier (see {@link Pattern}).
* @param diffType This edit class matches only {@link DiffNode}s of the given {@link DiffType}.
*/
public EditClass(final String name, final DiffType diffType) {
super(name);
this.diffType = diffType;
}
/**
* Returns the diff type nodes matched by this edit class.
*/
public DiffType getDiffType() {
return diffType;
}
/**
* Returns true iff the given node matches this edit class.
* @param artifactNode Node which has node type ARTIFACT and whose DiffType is the same as {@link getDiffType()}.
*/
protected abstract boolean matchesArtifactNode(DiffNode<?> artifactNode);
/**
* Returns true if this edit class matches the given node and is an artifact.
*/
@Override
public final boolean matches(DiffNode<?> node) {
return node.isArtifact() && node.diffType == diffType && matchesArtifactNode(node);
}
/**
* Returns true iff this edit class matches at leat one node on the given tree.
*/
public boolean anyMatch(final VariationDiff<?> t) {
return t.anyMatch(this::matches);
}
}