• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Query类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.objectbox.query.Query的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Query类属于io.objectbox.query包,在下文中一共展示了Query类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createListItemEmitter

import io.objectbox.query.Query; //导入依赖的package包/类
static <T> void createListItemEmitter(final Query<T> query, final FlowableEmitter<T> emitter) {
    final DataSubscription dataSubscription = query.subscribe().observer(new DataObserver<List<T>>() {
        @Override
        public void onData(List<T> data) {
            for (T datum : data) {
                if (emitter.isCancelled()) {
                    return;
                } else {
                    emitter.onNext(datum);
                }
            }
            if (!emitter.isCancelled()) {
                emitter.onComplete();
            }
        }
    });
    emitter.setCancellable(new Cancellable() {
        @Override
        public void cancel() throws Exception {
            dataSubscription.cancel();
        }
    });
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:24,代码来源:RxQuery.java


示例2: observable

import io.objectbox.query.Query; //导入依赖的package包/类
/**
 * The returned Observable emits Query results as Lists.
 * Never completes, so you will get updates when underlying data changes.
 */
public static <T> Observable<List<T>> observable(final Query<T> query) {
    return Observable.create(new ObservableOnSubscribe<List<T>>() {
        @Override
        public void subscribe(final ObservableEmitter<List<T>> emitter) throws Exception {
            final DataSubscription dataSubscription = query.subscribe().observer(new DataObserver<List<T>>() {
                @Override
                public void onData(List<T> data) {
                    if (!emitter.isDisposed()) {
                        emitter.onNext(data);
                    }
                }
            });
            emitter.setCancellable(new Cancellable() {
                @Override
                public void cancel() throws Exception {
                    dataSubscription.cancel();
                }
            });
        }
    });
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:26,代码来源:RxQuery.java


示例3: single

import io.objectbox.query.Query; //导入依赖的package包/类
/**
 * The returned Single emits one Query result as a List.
 */
public static <T> Single<List<T>> single(final Query<T> query) {
    return Single.create(new SingleOnSubscribe<List<T>>() {
        @Override
        public void subscribe(final SingleEmitter<List<T>> emitter) throws Exception {
            final DataSubscription dataSubscription = query.subscribe().single().observer(new DataObserver<List<T>>() {
                @Override
                public void onData(List<T> data) {
                    if (!emitter.isDisposed()) {
                        emitter.onSuccess(data);
                    }
                }
            });
            emitter.setCancellable(new Cancellable() {
                @Override
                public void cancel() throws Exception {
                    dataSubscription.cancel();
                }
            });
        }
    });
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:25,代码来源:RxQuery.java


示例4: testOldReaderWithIndex

import io.objectbox.query.Query; //导入依赖的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());
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:22,代码来源:IndexReaderRenewTest.java


示例5: flowableOneByOne

import io.objectbox.query.Query; //导入依赖的package包/类
/**
 * The returned Flowable emits Query results one by one. Once all results have been processed, onComplete is called.
 * Uses given BackpressureStrategy.
 */
public static <T> Flowable<T> flowableOneByOne(final Query<T> query, BackpressureStrategy strategy) {
    return Flowable.create(new FlowableOnSubscribe<T>() {
        @Override
        public void subscribe(final FlowableEmitter<T> emitter) throws Exception {
            createListItemEmitter(query, emitter);
        }

    }, strategy);
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:14,代码来源:RxQuery.java


示例6: updateUI

import io.objectbox.query.Query; //导入依赖的package包/类
private void updateUI() {
    // getting items and refreshing list
    Query<TrainingSet> querySetsBySessionId
            = mTrainingSetBox.query().equal(TrainingSet_.sessionId, mSessionId)
            .build();

    List<TrainingSet> filteredRecords = querySetsBySessionId.find();

    refreshList(filteredRecords);
}
 
开发者ID:coldsteelbr,项目名称:simple_fitness_diary,代码行数:11,代码来源:TrainingSessionActivity.java


示例7: updateUI

import io.objectbox.query.Query; //导入依赖的package包/类
private void updateUI() {
    // getting items and refreshing list
    Query<TrainingSession> queryAll
            = mTrainingSessionBox.query()
            .build();

    List<TrainingSession> filteredRecords = queryAll.find();

    refreshList(filteredRecords);
}
 
开发者ID:coldsteelbr,项目名称:simple_fitness_diary,代码行数:11,代码来源:TrainingSessionListActivity.java


示例8: queryAnimeList

import io.objectbox.query.Query; //导入依赖的package包/类
@Override
public Query<Anime> queryAnimeList(String serverUrl) {
    QueryBuilder<Anime> query = getAnimeBox().query();
    query.contains(Anime_.url, serverUrl);
    query.order(Anime_.title);
    return query.build();
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:8,代码来源:ObjectBoxRepository.java


示例9: queryEpisodes

import io.objectbox.query.Query; //导入依赖的package包/类
@Override
public Query<Episode> queryEpisodes(String animeUrl) {
    QueryBuilder<Episode> query = getEpisodeBox().query();
    query.contains(Episode_.animeUrl, animeUrl);
    query.order(Episode_.index);
    return query.build();
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:8,代码来源:ObjectBoxRepository.java


示例10: testRelationToOneQuery

import io.objectbox.query.Query; //导入依赖的package包/类
@Test
public void testRelationToOneQuery() {
    Customer customer = putCustomer();
    Order order = putOrder(customer, "Bananas");

    Query<Order> query = orderBox.query().equal(Order_.customerId, customer.getId()).build();
    Order orderFound = query.findUnique();
    assertEquals(order.getId(), orderFound.getId());
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:10,代码来源:RelationTest.java


示例11: testEagerToMany_NoResult

import io.objectbox.query.Query; //导入依赖的package包/类
@Test
public void testEagerToMany_NoResult() {
    Query<Customer> query = customerBox.query().eager(Customer_.orders).build();
    query.find();
    query.findFirst();
    query.forEach(new QueryConsumer<Customer>() {
        @Override
        public void accept(Customer data) {

        }
    });
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:13,代码来源:RelationEagerTest.java


示例12: testEagerToSingle_NoResult

import io.objectbox.query.Query; //导入依赖的package包/类
@Test
public void testEagerToSingle_NoResult() {
    Query<Order> query = orderBox.query().eager(Order_.customer).build();
    query.find();
    query.findFirst();
    query.forEach(new QueryConsumer<Order>() {
        @Override
        public void accept(Order data) {

        }
    });
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:13,代码来源:RelationEagerTest.java


示例13: testOverwriteIndexedValue

import io.objectbox.query.Query; //导入依赖的package包/类
@Test
public void testOverwriteIndexedValue() throws InterruptedException {
    final Box<EntityLongIndex> box = store.boxFor(EntityLongIndex.class);
    final int initialValue = 1;

    final EntityLongIndex[] transformResults = {null, null, null};
    final CountDownLatch transformLatch1 = new CountDownLatch(1);
    final CountDownLatch transformLatch2 = new CountDownLatch(1);
    final AtomicInteger transformerCallCount = new AtomicInteger();

    final Query<EntityLongIndex> query = box.query().equal(EntityLongIndex_.indexedLong, 0).build();
    store.subscribe(EntityLongIndex.class).transform(new DataTransformer<Class<EntityLongIndex>, EntityLongIndex>() {
        @Override
        public EntityLongIndex transform(Class<EntityLongIndex> clazz) throws Exception {
            int callCount = transformerCallCount.incrementAndGet();
            if (callCount == 1) {
                query.setParameter(EntityLongIndex_.indexedLong, 1);
                EntityLongIndex unique = query.findUnique();
                transformLatch1.countDown();
                return unique;
            } else if (callCount == 2) {
                query.setParameter(EntityLongIndex_.indexedLong, 1);
                transformResults[0] = query.findUnique();
                transformResults[1] = query.findUnique();
                query.setParameter(EntityLongIndex_.indexedLong, 0);
                transformResults[2] = query.findUnique();
                transformLatch2.countDown();
                return transformResults[0];
            } else {
                throw new RuntimeException("Unexpected: " + callCount);
            }
        }
    }).observer(new DataObserver<EntityLongIndex>() {
        @Override
        public void onData(EntityLongIndex data) {
            // Dummy
        }
    });

    assertTrue(transformLatch1.await(5, TimeUnit.SECONDS));
    box.put(createEntityLongIndex(initialValue));

    assertTrue(transformLatch2.await(5, TimeUnit.SECONDS));
    assertEquals(2, transformerCallCount.intValue());

    assertNotNull(transformResults[0]);
    assertNotNull(transformResults[1]);
    assertNull(transformResults[2]);

    query.setParameter(EntityLongIndex_.indexedLong, initialValue);
    assertNotNull(query.findUnique());

    query.setParameter(EntityLongIndex_.indexedLong, initialValue);
    assertNotNull(query.findUnique());
    assertNotNull(query.findUnique());
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:57,代码来源:IndexReaderRenewTest.java


示例14: testOldReaderInThread

import io.objectbox.query.Query; //导入依赖的package包/类
@Test
public void testOldReaderInThread() throws InterruptedException {
    final Box<EntityLongIndex> box = store.boxFor(EntityLongIndex.class);
    final int initialValue = 1;

    final EntityLongIndex[] results = new EntityLongIndex[5];
    final CountDownLatch latchRead1 = new CountDownLatch(1);
    final CountDownLatch latchPut = new CountDownLatch(1);
    final CountDownLatch latchRead2 = new CountDownLatch(1);
    final Query<EntityLongIndex> query = box.query().equal(EntityLongIndex_.indexedLong, 0).build();

    new Thread() {
        @Override
        public void run() {
            query.setParameter(EntityLongIndex_.indexedLong, initialValue);
            EntityLongIndex unique = query.findUnique();
            assertNull(unique);
            latchRead1.countDown();
            System.out.println("BEFORE put: " + box.getReaderDebugInfo());
            System.out.println("count before: " + box.count());

            try {
                latchPut.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
            System.out.println("AFTER put: " + box.getReaderDebugInfo());
            System.out.println("count after: " + box.count());

            query.setParameter(EntityLongIndex_.indexedLong, initialValue);
            results[0] = query.findUnique();
            results[1] = box.get(1);
            results[2] = query.findUnique();
            query.setParameter(EntityLongIndex_.indexedLong, 0);
            results[3] = query.findUnique();
            latchRead2.countDown();
        }
    }.start();

    assertTrue(latchRead1.await(5, TimeUnit.SECONDS));
    box.put(createEntityLongIndex(initialValue));
    latchPut.countDown();

    assertTrue(latchRead2.await(5, TimeUnit.SECONDS));

    assertNotNull(results[1]);
    assertNotNull(results[0]);
    assertNotNull(results[2]);
    assertNull(results[3]);

    query.setParameter(EntityLongIndex_.indexedLong, initialValue);
    assertNotNull(query.findUnique());

    query.setParameter(EntityLongIndex_.indexedLong, initialValue);
    assertNotNull(query.findUnique());
    assertNotNull(query.findUnique());
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:59,代码来源:IndexReaderRenewTest.java


示例15: queryAnimeList

import io.objectbox.query.Query; //导入依赖的package包/类
Query<Anime> queryAnimeList(String serverUrl); 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:2,代码来源:RxDataRepository.java


示例16: queryEpisodes

import io.objectbox.query.Query; //导入依赖的package包/类
Query<Episode> queryEpisodes(String animeUrl); 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:2,代码来源:RxDataRepository.java



注:本文中的io.objectbox.query.Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RemoveAclEntriesResponseProto类代码示例发布时间:2022-05-22
下一篇:
Java ClassParser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap