/** * Apply DeMorgan's Laws to push AND/OR constraints higher. */ @Override public ConstraintImpl simplify() { ConstraintImpl simple = constraint.simplify(); ConstraintImpl not = simple.not(); if (not != null) { return not.simplify(); } else if (simple != constraint) { return new NotImpl(simple); } return this; }
/** * Apply DeMorgan's Laws to push AND/OR constraints higher. */ @Override public ConstraintImpl simplify() { ConstraintImpl simple = constraint.simplify(); ConstraintImpl not = simple.not(); if (not != null) { return not.simplify(); } else if (simple != constraint) { return new NotImpl(simple); } return this; }
/** * Apply DeMorgan's Laws to push AND/OR constraints higher. */ @Override public ConstraintImpl simplify() { ConstraintImpl simple = constraint.simplify(); ConstraintImpl not = simple.not(); if (not != null) { return not.simplify(); } else if (simple != constraint) { return new NotImpl(simple); } return this; }
@Override public ConstraintImpl simplify() { // Use LinkedHashSet to eliminate duplicate constraints while keeping // the ordering for test cases (and clients?) that depend on it LinkedHashSet<ConstraintImpl> simplified = newLinkedHashSet(); boolean changed = false; // keep track of changes in simplification for (ConstraintImpl constraint : constraints) { ConstraintImpl simple = constraint.simplify(); if (simple instanceof AndImpl) { // unwind nested AND constraints simplified.addAll(((AndImpl) simple).constraints); changed = true; } else if (simplified.add(simple)) { // check if this constraint got simplified changed = changed || simple != constraint; } else { // this constraint was a duplicate of a previous one changed = true; } } if (simplified.size() == 1) { return simplified.iterator().next(); } else if (changed) { return new AndImpl(newArrayList(simplified)); } else { return this; } }
@Override public ConstraintImpl simplify() { // Use LinkedHashSet to eliminate duplicate constraints while keeping // the ordering for test cases (and clients?) that depend on it LinkedHashSet<ConstraintImpl> simplified = newLinkedHashSet(); boolean changed = false; // keep track of changes in simplification for (ConstraintImpl constraint : constraints) { ConstraintImpl simple = constraint.simplify(); if (simple instanceof AndImpl) { // unwind nested AND constraints simplified.addAll(((AndImpl) simple).constraints); changed = true; } else if (simplified.add(simple)) { // check if this constraint got simplified changed = changed || simple != constraint; } else { // this constraint was a duplicate of a previous one changed = true; } } if (simplified.size() == 1) { return simplified.iterator().next(); } else if (changed) { return new AndImpl(newArrayList(simplified)); } else { return this; } }
@Override public ConstraintImpl simplify() { // Use LinkedHashSet to eliminate duplicate constraints while keeping // the ordering for test cases (and clients?) that depend on it LinkedHashSet<ConstraintImpl> simplified = newLinkedHashSet(); boolean changed = false; // keep track of changes in simplification for (ConstraintImpl constraint : constraints) { ConstraintImpl simple = constraint.simplify(); if (simple instanceof AndImpl) { // unwind nested AND constraints simplified.addAll(((AndImpl) simple).constraints); changed = true; } else if (simplified.add(simple)) { // check if this constraint got simplified changed = changed || simple != constraint; } else { // this constraint was a duplicate of a previous one changed = true; } } if (simplified.size() == 1) { return simplified.iterator().next(); } else if (changed) { return new AndImpl(newArrayList(simplified)); } else { return this; } }
ConstraintImpl simple = constraint.simplify(); if (simple instanceof OrImpl) {
ConstraintImpl simple = constraint.simplify(); if (simple instanceof OrImpl) {
ConstraintImpl simple = constraint.simplify(); if (simple instanceof OrImpl) {
constraint = constraint.simplify();
constraint = constraint.simplify();
constraint = constraint.simplify();