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); }
protected final SqlSubjectData newWithUpdate( Map<Set<Entry<String, String>>, Segment> segments, ThrowingBiConsumer<SqlDao, SqlSubjectData, SQLException> updateFunc) { return new SqlSubjectData( subject, segments, Util.appendImmutable(this.updatesToPerform.get(), updateFunc)); }