All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.slee.profile.query.And Maven / Gradle / Ivy

package javax.slee.profile.query;

/**
 * The And class is a composite dynamic query expression that
 * successfully matches with a profile only if all nested query expressions
 * also match with the profile.
 */
public final class And extends CompositeQueryExpression {
    /**
     * Create an And query expression initially populated with the two
     * specified query expressions.
     * @param expr1 the first query expression to add.
     * @param expr2 the second query expression to add.
     * @throws NullPointerException if either argument is null.
     */
    public And(QueryExpression expr1, QueryExpression expr2) {
        add(expr1);
        add(expr2);
    }

    /**
     * Create an And query expression initially populated with the
     * expressions contained in the specified array.
     * @param exprs the query expressions to add.
     * @throws NullPointerException if exprs is null or
     *        contains null elements.
     * @throws IllegalArgumentException if the length of exprs is
     *        less than 2.
     */
    public And(QueryExpression[] exprs) {
        if (exprs == null) throw new NullPointerException("exprs is null");
        if (exprs.length < 2) throw new IllegalArgumentException("length of exprs must be at least 2");
        for (int i=0; ithis.
     * @throws NullPointerException if expr is null.
     * @throws IllegalArgumentException if adding the query expression to this
     *        composite expression would generate a cyclic expression.
     */
    public And and(QueryExpression expr) throws NullPointerException, IllegalArgumentException {
        add(expr);
        return this;
    }


    // protected

    // javadoc copied from parent
    protected void toString(StringBuffer buf) {
        QueryExpression[] exprs = getExpressions();
        for (int i=0; i0) buf.append(" && ");
            buf.append('(');
            exprs[i].toString(buf);
            buf.append(')');
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy