Ejemplo n.º 1
0
 protected final SqlSubjectData newWithUpdated(Set<Entry<String, String>> key, Segment val) {
   ThrowingBiConsumer<SqlDao, SqlSubjectData, SQLException> updateFunc;
   if (val.isEmpty()) { // then remove segment
     if (val.isUnallocated()) {
       updateFunc = (dao, data) -> {};
     } else {
       updateFunc = (dao, data) -> dao.removeSegment(val);
     }
   } else if (val.isUnallocated()) { // create new segment
     updateFunc =
         (dao, data) -> {
           Segment seg = data.segments.get(key);
           if (seg != null) {
             if (seg.isUnallocated()) {
               seg.popUpdates();
               dao.updateFullSegment(data.subject, seg);
             } else {
               seg.doUpdates(dao);
             }
           }
         };
   } else { // just run updates
     updateFunc =
         (dao, data) -> {
           val.doUpdates(dao);
         };
   }
   return newWithUpdate(Util.updateImmutable(segments, immutSet(key), val), updateFunc);
 }
Ejemplo n.º 2
0
 private ThrowingBiConsumer<SqlDao, SqlSubjectData, SQLException> createBulkUpdateFunc(
     Collection<Set<Entry<String, String>>> keys) {
   return (dao, data) -> {
     for (Set<Entry<String, String>> key : keys) {
       Segment seg = data.segments.get(key);
       if (seg != null) {
         if (seg.isEmpty()) {
           dao.removeSegment(seg);
         } else {
           seg.doUpdates(dao);
         }
       }
     }
   };
 }