private final void setTypeSerializerFactory(
      TypeSerializerFactory<?> factory, String classNameKey, String parametersPrefix) {
    // sanity check the factory type
    InstantiationUtil.checkForInstantiation(factory.getClass());

    // store the type
    this.config.setString(classNameKey, factory.getClass().getName());
    // store the parameters
    final DelegatingConfiguration parameters =
        new DelegatingConfiguration(this.config, parametersPrefix);
    factory.writeParametersToConfig(parameters);
  }
  private final <T> TypeSerializerFactory<T> getTypeSerializerFactory(
      String classNameKey, String parametersPrefix, ClassLoader cl) {
    // check the class name
    final String className = this.config.getString(classNameKey, null);
    if (className == null) {
      return null;
    }

    // instantiate the class
    @SuppressWarnings("unchecked")
    final Class<TypeSerializerFactory<T>> superClass =
        (Class<TypeSerializerFactory<T>>) (Class<?>) TypeSerializerFactory.class;
    final TypeSerializerFactory<T> factory;
    try {
      Class<? extends TypeSerializerFactory<T>> clazz =
          Class.forName(className, true, cl).asSubclass(superClass);
      factory = InstantiationUtil.instantiate(clazz, superClass);
    } catch (ClassNotFoundException cnfex) {
      throw new RuntimeException(
          "The class '"
              + className
              + "', noted in the configuration as "
              + "serializer factory, could not be found. It is not part of the user code's class loader resources.");
    } catch (ClassCastException ccex) {
      throw new CorruptConfigurationException(
          "The class noted in the configuration as the serializer factory "
              + "is no subclass of TypeSerializerFactory.");
    }

    // parameterize the comparator factory
    final Configuration parameters = new DelegatingConfiguration(this.config, parametersPrefix);
    try {
      factory.readParametersFromConfig(parameters, cl);
    } catch (ClassNotFoundException cnfex) {
      throw new RuntimeException(
          "The type serializer factory could not load its parameters from the "
              + "configuration due to missing classes.",
          cnfex);
    }

    return factory;
  }