/** * Deletes the {@code lists}, and all of their {@link RBookListItem}s, from Realm. * * @param realm Instance of Realm to use. * @param lists Lists to delete. */ public static void deleteLists(Realm realm, Collection<RBookList> lists) { if (lists != null && !lists.isEmpty()) { realm.executeTransaction( tRealm -> { for (RBookList list : lists) { // First, delete the list items (unless this is a smart list). if (!list.isSmartList) list.listItems.deleteAllFromRealm(); // Then, delete the book list. list.deleteFromRealm(); } }); } }