final void crawlFromRoot(FormationComposite root) { for (FormationComponent component : root.getFormations()) { if (component.isLeaf()) { this.onLeafFound((FormationLeaf) component); } else { FormationComposite composite = (FormationComposite) component; this.onCompositeFound(composite); this.crawlFromRoot(composite); } } }
public FormationLeaf getLeafById(Long id) { if (id == null) { throw new IllegalArgumentException( "Cannot find a " + FormationLeaf.class + " if given id is null"); } this.refreshIfNeeded(); FormationComponent component = this.components.get(id); if (component == null || !component.isLeaf()) { return null; } return (FormationLeaf) component; }