public <T> DefaultSerializationProviderConfiguration addSerializerFor(Class<T> serializableClass, Class<? extends Serializer<T>> serializerClass, boolean overwrite) {
    if (serializableClass == null) {
      throw new NullPointerException("Serializable class cannot be null");
    }
    if (serializerClass == null) {
      throw new NullPointerException("Serializer class cannot be null");
    }

    if(!isConstructorPresent(serializerClass, ClassLoader.class)) {
      throw new IllegalArgumentException("The serializer: " + serializerClass.getName() + " does not have a constructor that takes in a ClassLoader.");
    }

    if (isConstructorPresent(serializerClass, ClassLoader.class, FileBasedPersistenceContext.class)) {
      LOGGER.warn(serializerClass.getName() + " class has a constructor that takes in a FileBasedPersistenceContext. " +
                  "Support for this constructor has been removed since version 3.2. Consider removing it.");
    }

    if (defaultSerializers.containsKey(serializableClass) && !overwrite) {
      throw new IllegalArgumentException("Duplicate serializer for class : " + serializableClass.getName());
    } else {
      defaultSerializers.put(serializableClass, serializerClass);
    }

    return this;
  }
public < T > DefaultSerializationProviderConfiguration addSerializerFor ( Class < T > serializableClass , Class < ? extends Serializer < T > > serializerClass , boolean overwrite ) { if ( serializableClass == null ) { throw new NullPointerException ( "Serializable class cannot be null" ) ; } if ( serializerClass == null ) { throw new NullPointerException ( "Serializer class cannot be null" ) ; } if ( ! isConstructorPresent ( serializerClass , ClassLoader . class ) ) { throw new IllegalArgumentException ( "The serializer: " + serializerClass . getName ( ) + " does not have a constructor that takes in a ClassLoader." ) ; } if ( isConstructorPresent ( serializerClass , ClassLoader . class , FileBasedPersistenceContext . class ) ) { LOGGER . warn ( serializerClass . getName ( ) + " class has a constructor that takes in a FileBasedPersistenceContext. " + "Support for this constructor has been removed since version 3.2. Consider removing it." ) ; } if ( defaultSerializers . containsKey ( serializableClass ) && ! overwrite ) { throw new IllegalArgumentException ( "Duplicate serializer for class : " + serializableClass . getName ( ) ) ; } else { defaultSerializers . put ( serializableClass , serializerClass ) ; } return this ; }
Adds a new {@link Serializer} mapping for the class {@code serializableClass}

@param serializableClass the {@code Class} to add the mapping for
@param serializerClass the {@link Serializer} type to use
@param overwrite indicates if an existing mapping is to be overwritten
@param <T> the type of instances to be serialized / deserialized
@return this configuration object

@throws NullPointerException if any argument is null
@throws IllegalArgumentException if a mapping for {@code serializableClass} already exists and {@code overwrite} is {@code false}