/** * Creates a new component with an id. * Only for testing and components that are not created via dependency injection. * * @throws NullPointerException if the given id is null */ protected AbstractComponent(ComponentId id) { initId(id); isDeconstructable = setIsDeconstructable(); }
private Object initId(Object component) { if (component instanceof AbstractComponent) { AbstractComponent abstractComponent = (AbstractComponent) component; if (abstractComponent.hasInitializedId() && !abstractComponent.getId().equals(componentId())) { throw new IllegalStateException( "Component with id '" + componentId() + "' is trying to set its component id explicitly: '" + abstractComponent.getId() + "'. " + "This is not allowed, so please remove any call to super() in your component's constructor."); } abstractComponent.initId(componentId()); } return component; }