@Override public void setParent(ClientConnector parent) { if (previouslyAttached && parent != null) { throw new IllegalStateException( "An extension can not be set to extend a new target after getting detached from the previous."); } Class<? extends ClientConnector> supportedParentType = getSupportedParentType(); if (parent == null || supportedParentType.isInstance(parent)) { internalSetParent(parent); previouslyAttached = true; } else { throw new IllegalArgumentException(getClass().getName() + " can only be attached to targets of type " + supportedParentType.getName() + " but attach to " + parent.getClass().getName() + " was attempted."); } }