Add helper methods
This commit is contained in:
parent
ff00ace5e4
commit
e82a7a89b2
@ -1624,6 +1624,23 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
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.
|
||||||
*
|
*
|
||||||
@ -1711,6 +1728,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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the stage number of the stage this component belongs to. The stages
|
* Return the stage number of the stage this component belongs to. The stages
|
||||||
|
Loading…
x
Reference in New Issue
Block a user