addConstraints method

Result addConstraints(
  1. List<Constraint> constraints
)

Attempts to add the constraints in the list to the solver. If it cannot add any for some reason, a cleanup is attempted so that either all constraints will be added or none.

Check the Result returned to make sure the operation succeeded. Any errors will be reported via the message property on the Result.

Possible Results:

  • Result.success: All constraints successfully added.
  • Result.duplicateConstraint: One of the constraints in the list was already in the solver or the same constraint was specified multiple times in the argument list. Remove the duplicates and try again.
  • Result.unsatisfiableConstraint: One or more constraints were at Priority.required but could not added because of conflicts with other constraints at the same priority. Lower the priority of these constraints and try again.

Implementation

Result addConstraints(List<Constraint> constraints) {
  Result applier(c) => addConstraint(c);
  Result undoer(c) => removeConstraint(c);

  return _bulkEdit(constraints, applier, undoer);
}