@SuppressWarnings("MethodDoesntCallSuperMethod")
  @Override
  public ModuleBasedConfiguration clone() {
    @SuppressWarnings("unchecked")
    ModuleBasedConfiguration<ConfigurationModule, T> configuration = (ModuleBasedConfiguration)Objects.requireNonNull(getFactory())
      .createTemplateConfiguration(getProject());
    configuration.setName(getName());

    // AbstractPythonRunConfiguration calls in the constructor and so, there is a chance that newly created configuration will have module, but old haven't
    // and so, on readExternal module will be lost
    RunConfigurationModule configurationModule = configuration.getConfigurationModule();
    String moduleName = StringUtil.nullize(configurationModule.getModuleName());

    boolean isUseReadWriteExternal = true;
    if (this instanceof PersistentStateComponent<?>) {
      @SuppressWarnings("unchecked")
      Class<?> stateClass = ComponentSerializationUtil.getStateClass((Class<? extends PersistentStateComponent>)getClass());
      if (stateClass != Element.class) {
        isUseReadWriteExternal = false;
        configuration.doCopyOptionsFrom(this);
      }
    }

    if (isUseReadWriteExternal) {
      final Element element = new Element(TO_CLONE_ELEMENT_NAME);
      try {
        writeExternal(element);
        configuration.readExternal(element);
        // we don't call super.clone(), but writeExternal doesn't copy transient fields in the options like isAllowRunningInParallel
        // so, we have to call copyFrom to ensure that state is fully cloned
        // MUST BE AFTER readExternal because readExternal set options to a new instance
        configuration.setAllowRunningInParallel(isAllowRunningInParallel());
      }
      catch (InvalidDataException | WriteExternalException e) {
        LOG.error(e);
        return null;
      }
    }
    if (moduleName != null && StringUtil.nullize(configurationModule.getModuleName()) == null) {
      configurationModule.setModuleName(moduleName);
    }
    return configuration;
  }
@SuppressWarnings("MethodDoesntCallSuperMethod")
  @Override
  public ModuleBasedConfiguration clone()