本文整理汇总了Java中org.greenrobot.greendao.query.LazyList类的典型用法代码示例。如果您正苦于以下问题:Java LazyList类的具体用法?Java LazyList怎么用?Java LazyList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LazyList类属于org.greenrobot.greendao.query包,在下文中一共展示了LazyList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSizeAndGetAndPeak
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testSizeAndGetAndPeak() {
ArrayList<TestEntity> list = insert(2);
LazyList<TestEntity> listLazy = dao.queryBuilder().build().listLazy();
assertEquals(list.size(), listLazy.size());
assertNull(listLazy.peek(0));
assertNull(listLazy.peek(1));
assertNotNull(listLazy.get(1));
assertNull(listLazy.peek(0));
assertNotNull(listLazy.peek(1));
assertNotNull(listLazy.get(0));
assertNotNull(listLazy.peek(0));
assertNotNull(listLazy.peek(1));
}
示例2: testUncached
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testUncached() {
insert(1);
LazyList<TestEntity> listLazy = dao.queryBuilder().build().listLazyUncached();
assertFalse(listLazy.isEmpty());
assertFalse(listLazy.isClosed());
TestEntity entity1 = listLazy.get(0);
TestEntity entity2 = listLazy.get(0);
assertEquals(entity1.getId(), entity2.getId());
if (identityScopeForDao == null) {
assertNotSame(entity1, entity2);
} else {
assertSame(entity1, entity2);
}
assertFalse(listLazy.isClosed());
try {
listLazy.loadRemaining();
fail("Not empty");
} catch (DaoException expected) {
// Expected, OK
}
listLazy.close();
assertTrue(listLazy.isClosed());
}
示例3: testRawQueryLazyList
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testRawQueryLazyList() {
ArrayList<TestEntity> list = insert(2);
LazyList<TestEntity> listLazy = dao.queryRawCreate("").listLazy();
assertEquals(list.size(), listLazy.size());
assertNull(listLazy.peek(0));
assertNull(listLazy.peek(1));
assertNotNull(listLazy.get(1));
assertNull(listLazy.peek(0));
assertNotNull(listLazy.peek(1));
assertNotNull(listLazy.get(0));
assertNotNull(listLazy.peek(0));
assertNotNull(listLazy.peek(1));
}
示例4: testMockitoMocks
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
@Test
public void testMockitoMocks() {
mock(DaoMaster.class).newSession();
mock(DaoSession.class).getDatabase();
mock(Database.class).getRawDatabase();
mock(DatabaseStatement.class).execute();
mock(IdentityScope.class).clear();
mock(AbstractDao.class).queryBuilder();
mock(MinimalEntityDao.class).queryBuilder();
mock(MinimalEntity.class).getId();
mock(Query.class).forCurrentThread();
mock(QueryBuilder.class).build();
mock(CountQuery.class).forCurrentThread();
mock(DeleteQuery.class).forCurrentThread();
mock(Join.class).getTablePrefix();
mock(LazyList.class).getLoadedCount();
mock(WhereCondition.class).appendValuesTo(null);
mock(Property.class).isNull();
mock(DaoException.class).getMessage();
}
示例5: testLazyList
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testLazyList() {
// save
final PgnigPrices prices = new PgnigPrices();
daoSession.insert(prices);
final PgnigBill bill = new PgnigBill();
bill.setPgnigPrices(prices);
daoSession.insert(bill);
// load
final LazyList<PgnigBill> billsFromDb = daoSession.getPgnigBillDao().queryBuilder().listLazy();
// test
assertEquals(1, billsFromDb.size());
assertNotNull(billsFromDb.get(0));
assertNotNull(billsFromDb.get(0).getPgnigPrices());
assertTrue(billsFromDb.isClosed());
}
示例6: oneByOne
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
/**
* Emits the resulting entities one by one, producing them on the fly ("streaming" entities).
* Unlike {@link #list()}, it does not wait for the query to gather all results. Thus, the first entities are
* immediately available as soon the underlying database cursor has data. This approach may be more memory
* efficient for large number of entities (or large entities) at the cost of additional overhead caused by a
* per-entity delivery through Rx.
*/
public Observable<T> oneByOne() {
Observable<T> observable = Observable.create(new OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> subscriber) {
try {
LazyList<T> lazyList = query.forCurrentThread().listLazyUncached();
try {
for (T entity : lazyList) {
if (subscriber.isUnsubscribed()) {
break;
}
subscriber.onNext(entity);
}
} finally {
lazyList.close();
}
if (!subscriber.isUnsubscribed()) {
subscriber.onCompleted();
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
subscriber.onError(e);
}
}
});
return wrap(observable);
}
示例7: testGetAll100Uncached
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testGetAll100Uncached() {
ArrayList<TestEntity> list = insert(100);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build()
.listLazyUncached();
assertIds(list, listLazy);
assertFalse(listLazy.isClosed());
listLazy.close();
}
示例8: testSublistUncached
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testSublistUncached() {
ArrayList<TestEntity> list = insert(10);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build().listLazyUncached();
try {
assertIds(list.subList(2,7), listLazy.subList(2,7));
} catch (DaoException e) {
assertEquals("This operation only works with cached lazy lists", e.getMessage());
}
}
示例9: testIteratorUncached
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testIteratorUncached() {
ArrayList<TestEntity> list = insert(100);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build()
.listLazyUncached();
testIterator(list, listLazy, true);
assertFalse(listLazy.isClosed());
listLazy.close();
}
示例10: testEmpty
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testEmpty() {
insert(1);
LazyList<TestEntity> listLazy = dao.queryBuilder().where(Properties.SimpleInteger.eq(-1)).build().listLazy();
assertTrue(listLazy.isEmpty());
assertTrue(listLazy.isClosed());
try {
listLazy.get(0);
fail("Not empty");
} catch (RuntimeException e) {
// Expected, OK
}
}
示例11: testClose
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testClose() {
insert(1);
LazyList<TestEntity> listLazy = dao.queryBuilder().build().listLazy();
assertFalse(listLazy.isEmpty());
assertFalse(listLazy.isClosed());
listLazy.get(0);
assertTrue(listLazy.isClosed());
// Closing again should not harm
listLazy.close();
listLazy.close();
}
示例12: testAutoClose
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testAutoClose() {
insert(10);
LazyList<TestEntity> lazyList = dao.queryBuilder().build().listLazyUncached();
CloseableListIterator<TestEntity> iterator = lazyList.listIteratorAutoClose();
while (iterator.hasNext()) {
assertFalse(lazyList.isClosed());
iterator.next();
}
assertTrue(lazyList.isClosed());
}
示例13: getHistory
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public static LazyList<History> getHistory() {
if (historyQuery == null)
historyQuery = getSession().getHistoryDao().queryBuilder()
.orderDesc(HistoryDao.Properties.DateFrom, HistoryDao.Properties.BillType, HistoryDao.Properties.BillId)
.build();
return historyQuery.listLazy();
}
示例14: testGetAll100
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testGetAll100() {
ArrayList<TestEntity> list = insert(100);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build().listLazy();
assertIds(list, listLazy);
assertTrue(listLazy.isClosed());
}
示例15: testSublist
import org.greenrobot.greendao.query.LazyList; //导入依赖的package包/类
public void testSublist() {
ArrayList<TestEntity> list = insert(10);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build().listLazy();
assertIds(list.subList(2, 7), listLazy.subList(2, 7));
}