forked from VariantSync/DiffDetective
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariationLabel.java
More file actions
57 lines (47 loc) · 1.73 KB
/
Copy pathVariationLabel.java
File metadata and controls
57 lines (47 loc) · 1.73 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
52
53
54
55
56
57
package org.variantsync.diffdetective.variation;
import java.util.List;
import org.variantsync.diffdetective.variation.tree.HasNodeType;
import org.variantsync.diffdetective.variation.tree.VariationTree; // For Javadoc
import org.variantsync.functjonal.Cast;
/**
* Extends an inner {@link Label}, the object language, with variability, the meta language.
*
* This class allows encoding of multiple levels of variability in the sense of variation trees of
* variation trees. Such higher-order variation trees can be encoded in a single tree structure
* because the result of configuring a variation tree is still a tree. In other words: the object
* language of a {@code VariationTree<L>} is a tree with labels {@code L}. The trick is that a
* variation tree is just a tree with labels {@code VariationLabel<L>}.
*
* @param <L> the label of the trees (the object language) over which variability is introduced
* @see VariationTree
*/
public class VariationLabel<L extends Label> implements Label, HasNodeType {
private NodeType type;
private L innerLabel;
public VariationLabel(NodeType type, L innerLabel) {
this.type = type;
this.innerLabel = innerLabel;
}
public L getInnerLabel() {
return innerLabel;
}
public void setInnerLabel(L innerLabel) {
this.innerLabel = innerLabel;
}
@Override
public List<String> getLines() {
return innerLabel.getLines();
}
@Override
public NodeType getNodeType() {
return type;
}
@Override
public VariationLabel<L> clone() {
return new VariationLabel<L>(type, Cast.unchecked(innerLabel.clone()));
}
@Override
public String toString() {
return innerLabel.toString();
}
}