本文整理汇总了Java中io.objectbox.Box类的典型用法代码示例。如果您正苦于以下问题:Java Box类的具体用法?Java Box怎么用?Java Box使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Box类属于io.objectbox包,在下文中一共展示了Box类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableInfo
import io.objectbox.Box; //导入依赖的package包/类
private static List<TableDataResponse.TableInfo> getTableInfo(BoxStore boxStore, int index) {
List<Class> allEntityClasses = new ArrayList<>(boxStore.getAllEntityClasses());
Log.e("App", " allEntityClasses " + allEntityClasses);
Box<Object> box = boxStore.boxFor(allEntityClasses.get(index));
Log.e("App", " set box store " + boxStore);
Log.e("App", " set box store " + box.count());
Log.e("App", " set box store " + Arrays.toString(box.getEntityInfo().getAllProperties()));
List<TableDataResponse.TableInfo> tableInfoList = new ArrayList<>();
for (Property property : box.getEntityInfo().getAllProperties()) {
TableDataResponse.TableInfo tableInfo = new TableDataResponse.TableInfo();
tableInfo.title = property.dbName;
tableInfo.isPrimary = true;
tableInfoList.add(tableInfo);
}
return tableInfoList;
}
示例2: setBoxStore
import io.objectbox.Box; //导入依赖的package包/类
public void setBoxStore(BoxStore boxStore) {
this.boxStore = boxStore;
List<Class> allEntityClasses = new ArrayList<>(boxStore.getAllEntityClasses());
Log.e("App", " allEntityClasses " + allEntityClasses);
Box<?> box = boxStore.boxFor(allEntityClasses.get(0));
Log.e("App", " set box store " + boxStore);
Log.e("App", " set box store " + box.count());
Log.e("App", " set box store " + Arrays.toString(box.getEntityInfo().getAllProperties()));
for (Object o : box.getAll()) {
Field[] fields = o.getClass().getFields();
for (Field field : fields) {
Log.e("App", "fields " + field.getName());
}
}
}
示例3: loadInBackground
import io.objectbox.Box; //导入依赖的package包/类
@Override
public Void loadInBackground() {
final Box<DbEntry> box =
((SimpleRssReader) getContext()).getBoxStore().boxFor(DbEntry.class);
for (int i = 0; i < mEntryUrls.size(); i++) {
final String entryUrl = mEntryUrls.get(i);
final String entryTitle = mEntryTitles.get(i);
final QueryBuilder<DbEntry> queryBuilder = box.query();
if (queryBuilder.contains(DbEntry_.entryTitle, entryTitle).build().find().isEmpty()) {
final DbEntry entry = new DbEntry();
entry.setEntryUrl(entryUrl);
entry.setEntryTitle(entryTitle);
box.put(entry);
}
queryBuilder.close();
}
return null;
}
示例4: loadInBackground
import io.objectbox.Box; //导入依赖的package包/类
@Override
public Void loadInBackground() {
final Box<DbEntry> box =
((SimpleRssReader) getContext()).getBoxStore().boxFor(DbEntry.class);
final QueryBuilder<DbEntry> queryBuilder = box.query();
if (mSortOrder == SORT_ORDER_DESCENDING) {
queryBuilder.orderDesc(DbEntry_.entryTitle);
} else {
queryBuilder.order(DbEntry_.entryTitle);
}
SavedEntries.addSavedEntries(queryBuilder.build().find());
queryBuilder.close();
return null;
}
示例5: LazyList
import io.objectbox.Box; //导入依赖的package包/类
LazyList(Box<E> box, long[] objectIds, boolean cacheEntities) {
if (box == null || objectIds == null) {
throw new NullPointerException("Illegal null parameters passed");
}
this.box = box;
this.objectIds = objectIds;
size = objectIds.length;
if (cacheEntities) {
entities = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
entities.add(null);
}
} else {
entities = null;
}
}
示例6: testDateParam
import io.objectbox.Box; //导入依赖的package包/类
@Test
public void testDateParam() {
store.close();
assertTrue(store.deleteAllFiles());
store = MyObjectBox.builder().baseDirectory(boxStoreDir).debugFlags(DebugFlags.LOG_QUERY_PARAMETERS).build();
Date now = new Date();
Order order = new Order();
order.setDate(now);
Box<Order> box = store.boxFor(Order.class);
box.put(order);
Query<Order> query = box.query().equal(Order_.date, 0).build();
assertEquals(0, query.count());
query.setParameter(Order_.date, now);
}
示例7: testOldReaderWithIndex
import io.objectbox.Box; //导入依赖的package包/类
@Test
public void testOldReaderWithIndex() throws InterruptedException {
final Box<EntityLongIndex> box = store.boxFor(EntityLongIndex.class);
final int initialValue = 1;
final Query<EntityLongIndex> query = box.query().equal(EntityLongIndex_.indexedLong, 0).build();
assertNull(query.findUnique());
System.out.println("BEFORE put: " + box.getReaderDebugInfo());
System.out.println("count before: " + box.count());
box.put(createEntityLongIndex(initialValue));
System.out.println("AFTER put: " + box.getReaderDebugInfo());
System.out.println("count after: " + box.count());
query.setParameter(EntityLongIndex_.indexedLong, initialValue);
assertNotNull(query.findUnique());
query.setParameter(EntityLongIndex_.indexedLong, 0);
assertNull(query.findUnique());
}
示例8: putAndGetCustomTypes
import io.objectbox.Box; //导入依赖的package包/类
private void putAndGetCustomTypes() {
CustomTypes customTypes = new CustomTypes();
customTypes.customType = CustomTypes.SimpleEnum.DEFAULT;
customTypes.customTypes = Collections.singletonList(CustomTypes.SimpleEnum.DEFAULT);
Box<CustomTypes> box = ExampleApp.getBoxStore(this).boxFor(CustomTypes.class);
long customTypeId = box.put(customTypes);
CustomTypes customTypesLoaded = box.get(customTypeId);
}
示例9: assingField
import io.objectbox.Box; //导入依赖的package包/类
static void assingField(TableDataResponse.ColumnData columnData, Field field, String type, Box<?> box, long id) {
try {
columnData.dataType = type;
columnData.value = field.get(box.get(id));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
示例10: loadInBackground
import io.objectbox.Box; //导入依赖的package包/类
@Override
public List<Integer> loadInBackground() {
final Box<DbEntry> box =
((SimpleRssReader) getContext()).getBoxStore().boxFor(DbEntry.class);
for (final int index : mPositions) {
box.remove(SavedEntries.getSavedEntryAt(index).getId());
SavedEntries.removeSavedEntryAt(index);
}
return mPositions;
}
示例11: Query
import io.objectbox.Box; //导入依赖的package包/类
Query(Box<T> box, long queryHandle, boolean hasOrder, List<EagerRelation> eagerRelations, QueryFilter<T> filter,
Comparator<T> comparator) {
this.box = box;
store = box.getStore();
queryAttempts = store.internalQueryAttempts();
handle = queryHandle;
this.hasOrder = hasOrder;
publisher = new QueryPublisher<>(this, box);
this.eagerRelations = eagerRelations;
this.filter = filter;
this.comparator = comparator;
}
示例12: providesLocalRepository
import io.objectbox.Box; //导入依赖的package包/类
@Provides
@NonNull
@Singleton
public LocalRepository providesLocalRepository(Box<ContributorEntity> localContributorBox,
ThreadConfiguration threadConfiguration) {
return new LocalRepository(localContributorBox, threadConfiguration);
}
示例13: getBox
import io.objectbox.Box; //导入依赖的package包/类
public Box getBox() {
return box;
}
示例14: provideBoxForTrainingSet
import io.objectbox.Box; //导入依赖的package包/类
@Provides
Box<TrainingSet> provideBoxForTrainingSet() {
return mStore.boxFor(TrainingSet.class);
}
示例15: provideBoxForTrainingTrainingSession
import io.objectbox.Box; //导入依赖的package包/类
@Provides
Box<TrainingSession> provideBoxForTrainingTrainingSession() {
return mStore.boxFor(TrainingSession.class);
}