protected void mergeCache(List<OBJECT> objects){
synchronized (this) {
    if (this.objectList != null) {
      objects=new ArrayList<>(objects);
      for (int i=0; i < objects.size(); i++) {
        OBJECT newObject=objects.get(i);
        String newObjectName=getObjectName(newObject);
        for (int k=0; k < objectList.size(); k++) {
          OBJECT oldObject=objectList.get(k);
          String oldObjectName=getObjectName(oldObject);
          if (newObjectName.equals(oldObjectName)) {
            objects.set(i,oldObject);
            break;
          }
        }
      }
    }
  }
  setCache(objects);
}

protected void mergeCache ( List < OBJECT > objects ) { synchronized ( this ) { if ( this . objectList != null ) { objects = new ArrayList < > ( objects ) ; for ( int i = 0 ; i < objects . size ( ) ; i ++ ) { OBJECT newObject = objects . get ( i ) ; String newObjectName = getObjectName ( newObject ) ; for ( int k = 0 ; k < objectList . size ( ) ; k ++ ) { OBJECT oldObject = objectList . get ( k ) ; String oldObjectName = getObjectName ( oldObject ) ; if ( newObjectName . equals ( oldObjectName ) ) { objects . set ( i , oldObject ) ; break ; } } } } } setCache ( objects ) ; }
merges new cache with existing . if objects with the same name were already cached - leave them in cache ( because they might be referenced somewhere ) .
