
com.adobe.cq.searchcollections.qom.Constraints Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2012 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.cq.searchcollections.qom;
import java.util.ArrayList;
import java.util.List;
import javax.jcr.RepositoryException;
import javax.jcr.query.qom.Constraint;
import javax.jcr.query.qom.QueryObjectModelFactory;
/**
* @deprecated
*/
public class Constraints {
public static Constraint and(
QueryObjectModelFactory factory, List constraints)
throws RepositoryException {
int n = constraints.size();
if (n == 0) {
return null;
} else if (n == 1) {
return constraints.get(0);
} else {
int m = n / 2;
return factory.and(
and(factory, constraints.subList(0, m)),
and(factory, constraints.subList(m, n)));
}
}
public static Constraint and(
QueryObjectModelFactory factory, Constraint... constraints)
throws RepositoryException {
List list = new ArrayList(constraints.length);
for (Constraint constraint : constraints) {
if (constraint != null) {
list.add(constraint);
}
}
return and(factory, list);
}
public static Constraint or(
QueryObjectModelFactory factory, List constraints)
throws RepositoryException {
int n = constraints.size();
if (n == 0) {
return null;
} else if (n == 1) {
return constraints.get(0);
} else {
int m = n / 2;
return factory.or(
or(factory, constraints.subList(0, m)),
or(factory, constraints.subList(m, n)));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy