當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。