public void walk(RobotWalker walker) { for (Enumeration i = this.children(); i.hasMoreElements(); ) { RobotComponent child = (RobotComponent) i.nextElement(); child.walk(walker); } walker.handleRobotComponent(this); }
@Override public boolean equals(Object oth) { if (oth instanceof RobotComponent) { RobotComponent other = (RobotComponent) oth; boolean equal = getFullName().equals(other.getFullName()) && getBaseType().equals(other.getBaseType()) && getProperties().equals(other.getProperties()) && getChildren().size() == other.getChildren().size(); if (equal) { for (int i = 0; i < getChildren().size(); i++) { equal = equal && getChildren().elementAt(i).equals(other.getChildren().elementAt(i)); } } return equal; } return false; }
/** * @param component The component type to check. * @return Whether it can support adding another component of that type. */ public boolean supports(RobotComponent data) { return (children != null && children.contains(data)) || this.supports(data.getBase()); }