private void finish(List<Long> newIds, Entity e) {
   adapter.store(e); // store sets the id for the entity if it is new.
   newIds.add(e.getId());
 }
 private Entity getEntity(Long id) {
   Entity e = adapter.getById(id);
   if (e == null) e = adapter.create();
   return e;
 }