@Override public boolean impliedPartExists() { // Although there are an infinite number of conditions which deny all inputs we only check for the // most basic "not alwaysFalse()" condition. return !_condition.equals(Conditions.alwaysFalse()); }
@Override public boolean visit(EqualCondition right) { // "Like" conditions are true only for strings, so it is distinct if the "equal" condition does not // contain a string constant which matches the "like" condition. return !(right.getValue() instanceof String && _left.matches((String) right.getValue())); }
@Nullable @Override public Condition visit(IntrinsicCondition condition, Void context) { Condition inverse = condition.getCondition().visit(this, null); if (inverse == null) { return null; } return Conditions.intrinsic(condition.getName(), inverse); }
@Override public final Boolean visit(AndCondition right, Void context) { // left is a subset of right only if left is a subset of each "and" condition for (Condition andCondition : right.getConditions()) { if (!andCondition.visit(this, context)) { return false; } } return true; }
@Override public final Boolean visit(OrCondition right, Void context) { // left is a subset of right only if left is a subset of at least one "or" condition for (Condition orCondition : right.getConditions()) { if (orCondition.visit(this, context)) { return true; } } return false; }
public Void visit(NotCondition condition, Void context) { return condition.getCondition().visit(this, null); }
@Override public boolean impliesAny() { // Although there are an infinite number of conditions which satisfy all inputs we only check for the // most basic "alwaysTrue()" condition. return _condition.equals(Conditions.alwaysTrue()); }
@Override public boolean equals(Object o) { return (this == o) || (o instanceof NotCondition) && _condition.equals(((NotCondition) o).getCondition()); }
private Void visitAll(Collection<Condition> conditions) { for (Condition condition : conditions) { condition.visit(this, null); } return null; } }
@Override public Boolean visit(IsCondition right, Void context) { // Example: gt(5) subset? is(number) if (right.getState() == State.DEFINED) { return true; } return (_left.getValue() instanceof String && right.getState() == State.STRING) || (_left.getValue() instanceof Number && right.getState() == State.NUM); }
@Override protected Condition parse(String input) throws Exception { return Conditions.fromString(input); } }
@Override public Boolean visit(LikeCondition right, Void context) { // Example: like("val*ue") subset? like("v*e") return _left.isSubsetOf(right); } };
@Override public boolean impliedPartExists() { // Although there are an infinite number of conditions which deny all inputs we only check for the // most basic "not alwaysFalse()" condition. return !_condition.equals(Conditions.alwaysFalse()); }
@Override public boolean impliesAny() { // Although there are an infinite number of conditions which satisfy all inputs we only check for the // most basic "alwaysTrue()" condition. return _condition.equals(Conditions.alwaysTrue()); }
private boolean visitAll(Collection<Condition> conditions) { // Check each contained condition. boolean requiresMetadata = false; for (Condition condition : conditions) { if (condition.visit(this, null)) { requiresMetadata = true; } } return requiresMetadata; }