Add helper methods
This commit is contained in:
parent
ff00ace5e4
commit
e82a7a89b2
@ -1623,6 +1623,23 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
checkState();
|
checkState();
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the parent and super-parent components of this component.
|
||||||
|
* @return parent and super-parents of this component
|
||||||
|
*/
|
||||||
|
public final List<RocketComponent> getParents() {
|
||||||
|
checkState();
|
||||||
|
List<RocketComponent> result = new LinkedList<>();
|
||||||
|
RocketComponent currComp = this;
|
||||||
|
|
||||||
|
while (currComp.parent != null) {
|
||||||
|
currComp = currComp.parent;
|
||||||
|
result.add(currComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the root component of the component tree.
|
* Get the root component of the component tree.
|
||||||
@ -1710,6 +1727,26 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all the component assemblies that are a parent or super-parent of this component
|
||||||
|
* @return list of ComponentAssembly components that are a parent or super-parent of this component
|
||||||
|
*/
|
||||||
|
public final List<RocketComponent> getParentAssemblies() {
|
||||||
|
checkState();
|
||||||
|
|
||||||
|
List<RocketComponent> result = new LinkedList<>();
|
||||||
|
RocketComponent currComp = this;
|
||||||
|
|
||||||
|
while (currComp.parent != null) {
|
||||||
|
currComp = currComp.parent;
|
||||||
|
if (currComp instanceof ComponentAssembly) {
|
||||||
|
result.add(currComp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user