|
34 | 34 | /** |
35 | 35 | * Representation of a concrete variation tree with source information. |
36 | 36 | * |
37 | | - * @param root the root of the variation tree |
38 | | - * @param source from which source code the variation tree was obtained |
39 | 37 | * @param <L> The type of label stored in this tree. |
40 | 38 | * |
41 | 39 | * @see VariationTreeNode |
42 | 40 | * @author Benjamin Moosherr |
43 | 41 | */ |
44 | | -public record VariationTree<L extends Label>( |
45 | | - VariationTreeNode<L> root, |
46 | | - Source source |
47 | | -) implements Source { |
48 | | - /** Creates a {@code VariationTree} with the given root and an unknown source. */ |
| 42 | +public class VariationTree<L extends Label> implements Source { |
| 43 | + private final VariationTreeNode<L> root; |
| 44 | + private final Source source; |
| 45 | + |
| 46 | + /** Creates a {@code VariationTree} with the given root and an {@link Source#Unknown unknown} source. */ |
49 | 47 | public VariationTree(VariationTreeNode<L> root) { |
50 | 48 | this(root, Source.Unknown); |
51 | 49 | } |
@@ -143,7 +141,7 @@ public static <T extends VariationNode<T, L>, L extends Label> VariationTree<L> |
143 | 141 | public VariationDiff<L> toVariationDiff(final Function<VariationTreeNode<L>, DiffNode<L>> nodeConverter) { |
144 | 142 | return new VariationDiff<>( |
145 | 143 | DiffNode.unchanged(nodeConverter, root()), |
146 | | - new CompositeSource("VariationTree.toVariationDiff", source()) |
| 144 | + new CompositeSource("VariationTree.toVariationDiff", source) |
147 | 145 | ); |
148 | 146 | } |
149 | 147 |
|
@@ -235,8 +233,16 @@ public void assertConsistency() { |
235 | 233 | forAllPreorder(VariationTreeNode::assertConsistency); |
236 | 234 | } |
237 | 235 |
|
| 236 | + public VariationTreeNode<L> root() { |
| 237 | + return root; |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * Returns the source of this VariationTree (i.e., the data this VariationTree was created from). |
| 242 | + * @see Source |
| 243 | + */ |
238 | 244 | public Source getSource() { |
239 | | - return source(); |
| 245 | + return source; |
240 | 246 | } |
241 | 247 |
|
242 | 248 | @Override |
|
0 commit comments