public synchronized void merge ( MonomerCache remoteMonomerCache ) throws IOException , MonomerException { Map < Monomer , Monomer > conflicts = getConflictedMonomerMap ( remoteMonomerCache ) ; if ( conflicts . size ( ) > 0 ) { throw new MonomerException ( "Local new monomer and remote monomer database conflict found" ) ; } else { Map < String , Map < String , Monomer > > monoDB = remoteMonomerCache . getMonomerDB ( ) ; Set < String > polymerTypeSet = monoDB . keySet ( ) ; for ( Iterator i = polymerTypeSet . iterator ( ) ; i . hasNext ( ) ; ) { String polymerType = ( String ) i . next ( ) ; Map < String , Monomer > map = monoDB . get ( polymerType ) ; Set < String > monomerSet = map . keySet ( ) ; for ( Iterator it = monomerSet . iterator ( ) ; it . hasNext ( ) ; ) { String id = ( String ) it . next ( ) ; Monomer m = map . get ( id ) ; addMonomer ( monomerDB , smilesMonomerDB , m ) ; } } } dbChanged = true ; }
merge remote monomerCache with local monomerCache will throw exception if conflicts found . Client needs to resolve conflicts prior to calling merge