hollow/src/main/java/com/netflix/hollow/api/producer/validation/DuplicateDataDetectionValidator.java
public static void addValidatorsForSchemaWithPrimaryKey(HollowProducer producer) {
        producer.getWriteEngine().getOrderedTypeStates().stream()
                .filter(ts -> ts.getSchema().getSchemaType() == SchemaType.OBJECT)
                .map(ts -> (HollowObjectSchema) ts.getSchema())
                .filter(hos -> hos.getPrimaryKey() != null)
                .map(HollowObjectSchema::getPrimaryKey)
                .forEach(k -> producer.addListener(new DuplicateDataDetectionValidator(k.getType())));
    }
public static void addValidatorsForSchemaWithPrimaryKey(HollowProducer producer) {
        producer.getWriteEngine().getOrderedTypeStates().stream()
                .filter(ts -> ts.getSchema().getSchemaType() == SchemaType.OBJECT)
                .map(ts -> (HollowObjectSchema) ts.getSchema())
                .filter(hos -> hos.getPrimaryKey() != null)
                .map(HollowObjectSchema::getPrimaryKey)
                .forEach(k -> producer.addListener(new DuplicateDataDetectionValidator(k.getType())));
    }
Registers {@code DuplicateDataDetectionValidator} validators with the given {@link HollowProducer producer} for
all object schema declared with a primary key.
<p>
This requires that the producer's data model has been initialized
(see {@link HollowProducer#initializeDataModel(Class[])} or a prior run cycle has implicitly initialized
the data model.
<p>
For each {@link HollowTypeWriteState write state} that has a {@link HollowObjectSchema object schema}
declared with a {@link PrimaryKey primary key} a {@code DuplicateDataDetectionValidator} validator
is instantiated, with the primary key type name, and registered with the given producer (if a
{@code DuplicateDataDetectionValidator} validator is not already registered for the same primary key type name).

@param producer the producer
@apiNote This method registers a {@code DuplicateDataDetectionValidator} validator with only the primary key type
name and not, in addition, the primary key fields.  This is to ensure, for the common case, duplicate listeners
are not registered by this method if listeners with the same type names were explicitly registered when
building the producer.
@see HollowProducer#initializeDataModel(Class[])