use of org.btrplace.model.constraint.RunningCapacity in project scheduler by btrplace.
the class RunningCapacityBuilder method buildConstraint.
@Override
public List<? extends SatConstraint> buildConstraint(BtrPlaceTree t, List<BtrpOperand> args) {
if (!checkConformance(t, args)) {
return Collections.emptyList();
}
@SuppressWarnings("unchecked") List<Node> ns = (List<Node>) params[0].transform(this, t, args.get(0));
BtrpNumber n = (BtrpNumber) args.get(1);
if (!n.isInteger()) {
t.ignoreError("Parameter '" + params[1].getName() + "' expects an integer");
return Collections.emptyList();
}
int v = n.getIntValue();
if (v < 0) {
t.ignoreError("Parameter '" + params[1].getName() + "' expects a positive integer (" + v + " given)");
return Collections.emptyList();
}
return ns != null ? Collections.singletonList(new RunningCapacity(new HashSet<>(ns), v)) : Collections.emptyList();
}
Aggregations