private PersistenceUnitMetadataHolder normalize(List<PersistenceUnitMetadataHolder> listPUHolders) {
        // eliminate duplicates (keeping the first instance of each PU by name)
        Map<String, PersistenceUnitMetadata> flattened = new HashMap<String, PersistenceUnitMetadata>();
        for (PersistenceUnitMetadataHolder puHolder : listPUHolders) {
            for (PersistenceUnitMetadata pu : puHolder.getPersistenceUnits()) {
                if (!flattened.containsKey(pu.getPersistenceUnitName())) {
                    flattened.put(pu.getPersistenceUnitName(), pu);
                } else {
                    PersistenceUnitMetadata first = flattened.get(pu.getPersistenceUnitName());
                    PersistenceUnitMetadata duplicate = pu;
                    ROOT_LOGGER.duplicatePersistenceUnitDefinition(duplicate.getPersistenceUnitName(), first.getScopedPersistenceUnitName(), duplicate.getScopedPersistenceUnitName());
                }
            }
        }
        PersistenceUnitMetadataHolder holder = new PersistenceUnitMetadataHolder(new ArrayList<PersistenceUnitMetadata>(flattened.values()));
        return holder;
    }
private PersistenceUnitMetadataHolder normalize(List<PersistenceUnitMetadataHolder> listPUHolders) {
        
        Map<String, PersistenceUnitMetadata> flattened = new HashMap<String, PersistenceUnitMetadata>();
        for (PersistenceUnitMetadataHolder puHolder : listPUHolders) {
            for (PersistenceUnitMetadata pu : puHolder.getPersistenceUnits()) {
                if (!flattened.containsKey(pu.getPersistenceUnitName())) {
                    flattened.put(pu.getPersistenceUnitName(), pu);
                } else {
                    PersistenceUnitMetadata first = flattened.get(pu.getPersistenceUnitName());
                    PersistenceUnitMetadata duplicate = pu;
                    ROOT_LOGGER.duplicatePersistenceUnitDefinition(duplicate.getPersistenceUnitName(), first.getScopedPersistenceUnitName(), duplicate.getScopedPersistenceUnitName());
                }
            }
        }
        PersistenceUnitMetadataHolder holder = new PersistenceUnitMetadataHolder(new ArrayList<PersistenceUnitMetadata>(flattened.values()));
        return holder;
    }
private PersistenceUnitMetadataHolder normalize ( List < PersistenceUnitMetadataHolder > listPUHolders ) { // eliminate duplicates (keeping the first instance of each PU by name) Map < String , PersistenceUnitMetadata > flattened = new HashMap < String , PersistenceUnitMetadata > ( ) ; for ( PersistenceUnitMetadataHolder puHolder : listPUHolders ) { for ( PersistenceUnitMetadata pu : puHolder . getPersistenceUnits ( ) ) { if ( ! flattened . containsKey ( pu . getPersistenceUnitName ( ) ) ) { flattened . put ( pu . getPersistenceUnitName ( ) , pu ) ; } else { PersistenceUnitMetadata first = flattened . get ( pu . getPersistenceUnitName ( ) ) ; PersistenceUnitMetadata duplicate = pu ; ROOT_LOGGER . duplicatePersistenceUnitDefinition ( duplicate . getPersistenceUnitName ( ) , first . getScopedPersistenceUnitName ( ) , duplicate . getScopedPersistenceUnitName ( ) ) ; } } } PersistenceUnitMetadataHolder holder = new PersistenceUnitMetadataHolder ( new ArrayList < PersistenceUnitMetadata > ( flattened . values ( ) ) ) ; return holder ; }
Eliminate duplicate PU definitions from clustering the deployment (first definition will win)
<p/>
JPA 8.2  A persistence unit must have a name. Only one persistence unit of any given name must be defined
within a single EJB-JAR file, within a single WAR file, within a single application client jar, or within
an EAR. See Section 8.2.2, “Persistence Unit Scope”.

@param listPUHolders
@return
Eliminate duplicate PU definitions from clustering the deployment ( first definition will win ) <p / > JPA 8 . 2 A persistence unit must have a name . Only one persistence unit of any given name must be defined within a single EJB - JAR file within a single WAR file within a single application client jar or within an EAR . See Section 8 . 2 . 2 “Persistence Unit Scope” .