当前位置: 首页>>代码示例>>Java>>正文


Java InPredicate类代码示例

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


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

示例1: splitMultiValuePredicate

import org.kuali.rice.core.api.criteria.InPredicate; //导入依赖的package包/类
/**
 * This method takes in a multi-value predicate which has more values than
 * can fit into a single SQL clause and splits them up into multiple
 * clauses which are concatenated by an OR statement.
 * @param p The predicate which needs to be split into smaller predicates
 * @param parent The criteria to add the predicate to
 */
private void splitMultiValuePredicate(MultiValuedPredicate p, C parent) {
    final String pp = p.getPropertyPath();
    int chunkCount = (int)Math.ceil(p.getValues().size() / (double)MULTI_VALUE_CHUNK_SIZE);
    Predicate[] multiValuePredicateChunks = new Predicate[chunkCount];
    Object[] values = p.getValues().toArray();
    int start = 0;
    for(int i = 0; i < chunkCount; i++) {
        Object[] valueChunk = Arrays.copyOfRange(values, start, start + MULTI_VALUE_CHUNK_SIZE);
        if (p instanceof InPredicate) {
            multiValuePredicateChunks[i] = PredicateFactory.in(pp, valueChunk);
        } else if (p instanceof InIgnoreCasePredicate) {
            multiValuePredicateChunks[i] = PredicateFactory.inIgnoreCase(pp, (CharSequence[])valueChunk);
        } else if (p instanceof NotInPredicate) {
            multiValuePredicateChunks[i] = PredicateFactory.notIn(pp, valueChunk);
        } else if (p instanceof NotInIgnoreCasePredicate) {
            multiValuePredicateChunks[i] = PredicateFactory.notInIgnoreCase(pp, (CharSequence[])valueChunk);
        } else {
            throw new UnsupportedPredicateException(p);
        }

        start += MULTI_VALUE_CHUNK_SIZE;
    }
    addPredicate(PredicateFactory.or(multiValuePredicateChunks), parent);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:32,代码来源:QueryTranslatorBase.java


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