mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-08 18:46:12 +00:00
GraphTargetVisitorInterface for visiting model
This commit is contained in:
@@ -501,6 +501,19 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
visit(new AbstractGraphTargetVisitor() {
|
||||
@Override
|
||||
public void visit(GraphTargetItem item) {
|
||||
if (item != null) {
|
||||
ret.add(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<GraphTargetItem> getAllSubItemsRecursively() {
|
||||
Set<GraphTargetItem> ret = new HashSet<>();
|
||||
visitRecursively(new AbstractGraphTargetVisitor() {
|
||||
@Override
|
||||
public void visit(GraphTargetItem item) {
|
||||
ret.add(item);
|
||||
@@ -509,6 +522,20 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final void visitRecursively(GraphTargetVisitorInterface visitor) {
|
||||
Set<GraphTargetItem> visitedItems = new HashSet<>();
|
||||
visit(new AbstractGraphTargetVisitor() {
|
||||
@Override
|
||||
public void visit(GraphTargetItem item) {
|
||||
if (item != null && !visitedItems.contains(item)) {
|
||||
visitedItems.add(item);
|
||||
visitor.visit(item);
|
||||
item.visit(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void visit(GraphTargetVisitorInterface visitor) {
|
||||
if (value != null) {
|
||||
visitor.visit(value);
|
||||
|
||||
Reference in New Issue
Block a user