Component implements HasElement, AttachNotifier, DetachNotifier { private static void setElement(Component component, Element element, boolean mapElementToComponent) { if (component.element != null) { throw new IllegalStateException("Element has already been set"); } if (element == null) { throw new IllegalArgumentException("Element must not be null"); } component.element = element; if (mapElementToComponent) { ElementUtil.setComponent(element, component); component.configureSynchronizedProperties(); } } 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 setElement() { Component c = new Component(null) { }; Element element = ElementFactory.createDiv(); Component.setElement(c, element); Assert.assertEquals(c, element.getComponent().get()); Assert.assertEquals(element, c.getElement()); }
@Test(expected = IllegalArgumentException.class) public void setElementNull() { Component c = new Component(null) { }; Component.setElement(c, null); }
@Test(expected = IllegalStateException.class) public void setElementTwice() { Component c = new Component(null) { }; Element element = ElementFactory.createDiv(); Component.setElement(c, element); Component.setElement(c, element); }