public void replaceMapChildren ( Map < String , String > map , String parentId ) { ArrayList < StringEntity > entities = new ArrayList <> ( ) ; for ( String key : map . keySet ( ) ) { StringEntity entity = new StringEntity ( ) ; entity . setParentId ( parentId ) ; entity . setId ( key ) ; entity . setValue ( map . get ( key ) ) ; entities . add ( entity ) ; } replaceChildren ( entities , parentId ) ; }
This method allows to replace all children of a given parent it will remove any children which are not in the list add the new ones and update which are in the list .