io.objectbox.Box.removeAll()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中io.objectbox.Box.removeAll()方法的一些代码示例,展示了Box.removeAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Box.removeAll()方法的具体详情如下:
包路径:io.objectbox.Box
类名称:Box
方法名:removeAll

Box.removeAll介绍

[英]Removes (deletes) ALL Objects in a single transaction.
[中]移除(删除)单个事务中的所有对象。

代码示例

代码示例来源:origin: objectbox/objectbox-java

@Before
public void initBoxes() {
  deleteDbFiles();
  customerBox = store.boxFor(Customer.class);
  orderBox = store.boxFor(Order.class);
  customerBox.removeAll();
  orderBox.removeAll();
}

代码示例来源:origin: objectbox/objectbox-java

@Override
  public void run() {
    putTestEntities(2);
    box.removeAll();
    putTestEntity("hello", 3);
    counts[0] = box.count();
  }
});

代码示例来源:origin: objectbox/objectbox-java

@Test
public void testGetAllAfterGetAndRemove() {
  assertEquals(0, box.count());
  assertEquals(0, box.getAll().size());
  System.out.println("PUT");
  List<TestEntity> entities = putTestEntities(10);
  // explicitly get an entity (any will do)
  System.out.println("GET");
  TestEntity entity = box.get(entities.get(1).getId());
  assertNotNull(entity);
  System.out.println("REMOVE_ALL");
  box.removeAll();
  System.out.println("COUNT");
  assertEquals(0, box.count());
  System.out.println("GET_ALL");
  List<TestEntity> all = box.getAll();
  // note only 1 entity is returned by getAll, it is the one we explicitly get (last) above
  assertEquals(0, all.size());
}

代码示例来源:origin: objectbox/objectbox-java

@Test
public void testRemoveMany() {
  List<TestEntity> entities = new ArrayList<>();
  for (int i = 0; i < 10; i++) {
    TestEntity entity = new TestEntity();
    entity.setSimpleInt(2000 + i);
    entities.add(entity);
  }
  box.put(entities);
  assertEquals(entities.size(), box.count());
  box.remove(entities.get(1));
  assertEquals(entities.size() - 1, box.count());
  box.remove(entities.get(4), entities.get(5));
  assertEquals(entities.size() - 3, box.count());
  List<TestEntity> entitiesRemove = new ArrayList<>();
  entitiesRemove.add(entities.get(2));
  entitiesRemove.add(entities.get(8));
  entitiesRemove.add(entities.get(7));
  box.remove(entitiesRemove);
  assertEquals(entities.size() - 6, box.count());
  List<TestEntity> entitiesRead = box.getAll();
  assertEquals(entities.size() - 6, entitiesRead.size());
  assertEquals(2000, entitiesRead.get(0).getSimpleInt());
  assertEquals(2003, entitiesRead.get(1).getSimpleInt());
  assertEquals(2006, entitiesRead.get(2).getSimpleInt());
  assertEquals(2009, entitiesRead.get(3).getSimpleInt());
  box.removeAll();
  assertEquals(0, box.count());
}

代码示例来源:origin: objectbox/objectbox-java

@Test
public void testCountMaxAndIsEmpty() {
  assertTrue(box.isEmpty());
  putTestEntity("banana", 0);
  assertFalse(box.isEmpty());
  assertEquals(1, box.count(1));
  assertEquals(1, box.count(2));
  putTestEntity("apple", 0);
  assertEquals(2, box.count(2));
  assertEquals(2, box.count(3));
  box.removeAll();
  assertTrue(box.isEmpty());
}

代码示例来源:origin: fengzhizi715/RxCache4a

@Override
  public void evictAll() {

    cacheEntityBox.removeAll();
  }
}

代码示例来源:origin: objectbox/objectbox-examples

studentBox.removeAll();
teacherBox.removeAll();

代码示例来源:origin: objectbox/objectbox-examples

customerBox.removeAll();
orderBox.removeAll();

相关文章