Component implements HasElement, AttachNotifier, DetachNotifier { public Stream<Component> getChildren() { assert !(this instanceof Composite); if (!getElement().getComponent().isPresent()) { throw new IllegalStateException( "You cannot use getChildren() on a wrapped component. Use Component.wrapAndMap to include the component in the hierarchy"); } Builder<Component> childComponents = Stream.builder(); getElement().getChildren().forEach(childElement -> ComponentUtil .findComponents(childElement, childComponents::add)); return childComponents.build(); } protected  Component(); protected  Component(Element element); @Override Element getElement(); Optional<Component> getParent(); Stream<Component> getChildren(); Optional<UI> getUI(); void setId(String id); Optional<String> getId(); boolean isAttached(); static T from(Element element,
            Class<T> componentType); void setVisible(boolean visible); boolean isVisible(); void onEnabledStateChanged(boolean enabled); String getTranslation(String key, Object... params); String getTranslation(String key, Locale locale, Object... params);  }
@Test public void defaultGetChildrenNoChildren() { List<Component> children = parentDivComponent.getChildren() .collect(Collectors.toList()); Assert.assertArrayEquals( new Component[] { child1SpanComponent, child2InputComponent }, children.toArray()); }
@Test(expected = IllegalStateException.class) public void wrappedComponentGetChildren() { Element div = new Element("div"); Element button = new Element("button"); div.appendChild(button); button.as(TestButton.class); div.as(TestDiv.class).getChildren(); }