blob: 7723970c2b68478b183082cf972ca9cd0a4d00d4 (
plain) (
blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*****************************************************************************
* Copyright (c) 2017 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.profilemigration.internal.nodes;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.edit.tree.impl.TreeNodeImpl;
import com.google.common.collect.Iterables;
/**
* This class is wrapper for TreeNode used to represent a match TreeNode.
*/
public class MatchNode extends TreeNodeImpl {
/**
* Constructor.
*
* @param match
* The match represented by this TreeNode
*/
public MatchNode(Match match) {
setData(match);
}
/**
* Add the given MatchNode to the children of this MatchNode.
*
* @param matchNode
* The MatchNode to add
* @return <code>true</code> if the MatchNode has been added
*/
public boolean addSubMatchNode(MatchNode matchNode) {
return getChildren().add(matchNode);
}
/**
* Add the given DiffNode to the children of this MatchNode.
*
* @param diffNode
* The DiffNode to add
* @return <code>true</code> if the DiffNode has been added
*/
public boolean addDiffNode(DiffNode diffNode) {
return getChildren().add(diffNode);
}
/**
* Remove the given MatchNode of the children of this MatchNode.
*
* @param matchNode
* The MatchNode to remove
* @return <code>true</code> if the MatchNode has been removed
*/
public boolean removeSubMatchNode(MatchNode matchNode) {
return getChildren().remove(matchNode);
}
/**
* Remove the given DiffNode of the children of this MatchNode.
*
* @param diffNode
* The DiffNode to remove
* @return <code>true</code> if the DiffNode has been removed
*/
public boolean removeDiffNode(DiffNode diffNode) {
return getChildren().remove(diffNode);
}
/**
* Getter for the match represented by this TreeNode.
*
* @return the match
*/
public Match getMatch() {
return (Match) getData();
}
/**
* Get all the match trees that are submatches of the match
*
* @return an iterable of all submatches
*/
public Iterable<MatchNode> getSubMatchNodes() {
return Iterables.filter(getChildren(), MatchNode.class);
}
/**
* Get all the diffs that are part of the match
*
* @return an iterable of all directly contained diffs
*/
public Iterable<DiffNode> getDiffNodes() {
return Iterables.filter(getChildren(), DiffNode.class);
}
}
|