本文整理汇总了Java中org.kuali.rice.core.api.criteria.AndPredicate类的典型用法代码示例。如果您正苦于以下问题:Java AndPredicate类的具体用法?Java AndPredicate怎么用?Java AndPredicate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndPredicate类属于org.kuali.rice.core.api.criteria包,在下文中一共展示了AndPredicate类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyCompositePredicate
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
private Predicate applyCompositePredicate(final CompositePredicate input) {
Set<Predicate> appliedPredicates = new HashSet<Predicate>();
for (Predicate predicate : input.getPredicates()) {
appliedPredicates.add(applyPredicate(predicate));
}
Predicate[] appliedPredicatesArray = Iterables.toArray(appliedPredicates, Predicate.class);
if (input instanceof AndPredicate) {
return and(appliedPredicatesArray);
} else if (input instanceof OrPredicate) {
return or(appliedPredicatesArray);
}
return input;
}
示例2: testGenerateCriteria_BetweenDate
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
/**
* Criteria for BETWEEN dates should range from the start of the day on the lower date to the end of the day on the
* upper date.
*
* <p>
* Since the end of the day is defined as the moment before the next day, then the range that should be checked is
* [1/1/2010,1/2/2010), or in SQL, approximately >=2010-01-01 00:00:00 AND <=2010-01-03 00:00:00.
* </p>
*/
@Test
public void testGenerateCriteria_BetweenDate() {
String lowerDateString = "1/1/2010";
DateTime lowerDate = DateTime.parse(lowerDateString, formatter).withTimeAtStartOfDay();
String upperDateString = "1/2/2010";
DateTime upperDate = DateTime.parse(upperDateString, formatter).withTimeAtStartOfDay();
Map<String, String> mapCriteria = new HashMap<String, String>();
mapCriteria.put("prop4", lowerDateString + SearchOperator.BETWEEN.op() + upperDateString);
QueryByCriteria.Builder qbcBuilder = generator.generateCriteria(TestClass.class, mapCriteria, false);
assertNotNull(qbcBuilder);
QueryByCriteria qbc = qbcBuilder.build();
Predicate and = qbc.getPredicate();
assertTrue(and instanceof AndPredicate);
Set<Predicate> predicates = ((AndPredicate) and).getPredicates();
assertEquals(2, predicates.size());
boolean foundProp4Lower = false;
boolean foundProp4Upper = false;
for (Predicate predicate : predicates) {
if (predicate instanceof GreaterThanOrEqualPredicate) {
foundProp4Lower = true;
GreaterThanOrEqualPredicate greaterThanOrEqual = (GreaterThanOrEqualPredicate) predicate;
assertEquals(greaterThanOrEqual.getValue().getValue(), lowerDate);
} else if (predicate instanceof LessThanOrEqualPredicate) {
foundProp4Upper = true;
LessThanOrEqualPredicate lessThanOrEqual = (LessThanOrEqualPredicate) predicate;
assertEquals(lessThanOrEqual.getValue().getValue(), upperDate.plusDays(1));
}
}
assertTrue(foundProp4Lower);
assertTrue(foundProp4Upper);
}
示例3: addCompositePredicate
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
/**
* Adds a composite predicate to a criteria.
*
* @param p the composite predicate to add.
* @param parent the parent criteria to add to.
*/
protected void addCompositePredicate(final CompositePredicate p, final C parent) {
for (Predicate ip : p.getPredicates()) {
final C inner = createInnerCriteria(parent);
addPredicate(ip, inner);
if (p instanceof AndPredicate) {
addAnd(parent, inner);
} else if (p instanceof OrPredicate) {
addOr(parent, inner);
} else {
throw new UnsupportedPredicateException(p);
}
}
}
示例4: addCompositePredicate
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
/** adds a composite predicate to a Criteria. */
private void addCompositePredicate(final CompositePredicate p, final Criteria parent, LookupCustomizer.Transform<Predicate, Predicate> transform) {
for (Predicate ip : p.getPredicates()) {
final Criteria inner = new Criteria();
addPredicate(ip, inner, transform);
if (p instanceof AndPredicate) {
parent.addAndCriteria(inner);
} else if (p instanceof OrPredicate) {
parent.addOrCriteria(inner);
} else {
throw new UnsupportedPredicateException(p);
}
}
}
示例5: matches
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
/**
* protected for testing
*/
protected boolean matches(T infoObject, Predicate predicate) {
// no predicate matches everyting
if (predicate == null) {
return true;
}
if (predicate instanceof OrPredicate) {
return matchesOr(infoObject, (OrPredicate) predicate);
}
if (predicate instanceof AndPredicate) {
return matchesAnd(infoObject, (AndPredicate) predicate);
}
if (predicate instanceof EqualPredicate) {
return matchesEqual(infoObject, (EqualPredicate) predicate);
}
if (predicate instanceof LessThanPredicate) {
return matchesLessThan(infoObject, (LessThanPredicate) predicate);
}
if (predicate instanceof LessThanOrEqualPredicate) {
return matchesLessThanOrEqual(infoObject, (LessThanOrEqualPredicate) predicate);
}
if (predicate instanceof GreaterThanPredicate) {
return matchesGreaterThan(infoObject, (GreaterThanPredicate) predicate);
}
if (predicate instanceof GreaterThanOrEqualPredicate) {
return matchesGreaterThanOrEqual(infoObject, (GreaterThanOrEqualPredicate) predicate);
}
if (predicate instanceof LikePredicate) {
return matchesLike(infoObject, (LikePredicate) predicate);
}
throw new UnsupportedOperationException("predicate type not supported yet in in-memory mathcer" + predicate.getClass().getName());
}
示例6: matchesAnd
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
private boolean matchesAnd(T infoObject, AndPredicate predicate) {
for (Predicate subPred : predicate.getPredicates()) {
if (!matches(infoObject, subPred)) {
return false;
}
}
return true;
}
示例7: addCompositePredicate
import org.kuali.rice.core.api.criteria.AndPredicate; //导入依赖的package包/类
/** adds a composite predicate to a Criteria. */
private void addCompositePredicate(final CompositePredicate p, final Criteria parent, LookupCustomizer.Transform<Predicate, Predicate> transform) {
for (Predicate ip : p.getPredicates()) {
final Criteria inner = new Criteria(parent.getEntityName());
addPredicate(ip, inner, transform);
if (p instanceof AndPredicate) {
parent.and(inner);
} else if (p instanceof OrPredicate) {
parent.or(inner);
} else {
throw new UnsupportedPredicateException(p);
}
}
}