public void uniquify ( StorableKey < S > key ) { if ( key == null ) { throw new IllegalArgumentException ( ) ; } // Replace indexes which were are implied unique, even if they are not // declared as such. { Map < StorableIndex < S > , StorableIndex < S > > replacements = null ; for ( StorableIndex < S > index : this ) { if ( ! index . isUnique ( ) && isUniqueImplied ( index ) ) { if ( replacements == null ) { replacements = new HashMap < StorableIndex < S > , StorableIndex < S > > ( ) ; } replacements . put ( index , index . unique ( true ) ) ; } } replaceEntries ( replacements ) ; } // Now augment with key properties. { Map < StorableIndex < S > , StorableIndex < S > > replacements = null ; for ( StorableIndex < S > index : this ) { StorableIndex < S > replacement = index . uniquify ( key ) ; if ( replacement != index ) { if ( replacements == null ) { replacements = new HashMap < StorableIndex < S > , StorableIndex < S > > ( ) ; } replacements . put ( index , replacement ) ; } } replaceEntries ( replacements ) ; } }
Augment non - unique indexes with key properties thus making them unique .