Component implements HasElement, AttachNotifier, DetachNotifier { public Optional<Component> getParent() { Optional<Component> mappedComponent = getElement().getComponent(); if (!mappedComponent.isPresent()) { throw new IllegalStateException( "You cannot use getParent() on a wrapped component. Use Component.wrapAndMap to include the component in the hierarchy"); } if (isInsideComposite(mappedComponent.get())) { Component parent = ComponentUtil.getParentUsingComposite( (Composite<?>) mappedComponent.get(), this); return Optional.of(parent); } return ComponentUtil.findParentComponent(getElement().getParent()); } 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 getParentForDetachedComponent() { Assert.assertFalse(parentDivComponent.getParent().isPresent()); }
@Test(expected = IllegalStateException.class) public void wrappedComponentGetParent() { Element div = new Element("div"); Element button = new Element("button"); div.appendChild(button); div.as(TestDiv.class); button.as(TestButton.class).getParent(); }