/** * Equality is by value. * * @param object The ConstraintHaving object to compare to * @return <code>true</code> if object is the same as this. */ public boolean equals(Object object) { if (object == null) return false; if (object == this) return true; // Check that the given object is the correct class if (!object.getClass().equals(this.getClass())) return false; // Check each element. ConstraintHaving tmpConstraint = (ConstraintHaving) object; return element[0].equals(tmpConstraint.getElement(0)) && element[1].equals(tmpConstraint.getElement(1)) && element[2].equals(tmpConstraint.getElement(2)) && element[3].equals(tmpConstraint.getElement(3)); }
/** * Get all constraints which are variables. For back-compatibility, this * method currently ignores the fourth element of the triple. * * @return A set containing all variable constraints. */ public Set<Variable> getVariables() { if (variables == null) { Set<Variable> v = new HashSet<Variable>(); Variable e = getVariable(); if (!e.getName().startsWith("_")) v.add(e); if (element[3] instanceof Variable && !((Variable)element[3]).getName().startsWith("_")) { v.add((Variable)element[3]); } variables = Collections.unmodifiableSet(v); } return variables; }
(!havingConstraint.equals(query.havingConstraint))) { return false;
public RestrictPredicate duplicate(ConstraintHaving constraint, ResolverSession session) throws TuplesException { AbstractHavingPredicate pred = (AbstractHavingPredicate)clone(); pred.session = session; ConstraintElement rhs = constraint.getElement(2); if (rhs instanceof Variable) { pred.rhsVar = (Variable)rhs; } else { try { pred.rhsValue = session.localize((Value)rhs); } catch (LocalizeException el) { throw new TuplesException("Failed to localize rhs of restriction predicate: " + constraint); } } ConstraintElement lhs = constraint.getElement(0); if (!(lhs instanceof Variable)) { throw new TuplesException("Left-hand-side of restriction predicate is not variable"); } pred.lhsVar = (Variable)lhs; return pred; }