return Collections.singleton(new ValueSpecification(ValueRequirementNames.WEIGHT, target.toSpecification(), ValueProperties.all()));
}
@Override
public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
final ValueProperties constraints = desiredValue.getConstraints();
Set<String> values = constraints.getValues(VALUE_PROPERTY_NAME);
final String inputValue;
if ((values == null) || values.isEmpty()) {
inputValue = DEFAULT_VALUE_NAME;
} else if (values.size() == 1) {
inputValue = values.iterator().next();
} else {
return null;
}
// Propogate the desired value constraints onto the requirements, removing those specific to this function and adding a unit homogeneity clause
final ValueProperties.Builder requirementConstraintsBuilder = constraints.copy().withoutAny(VALUE_PROPERTY_NAME);
for (String unit : UnitProperties.unitPropertyNames()) {
values = constraints.getValues(unit);
if (values == null) {
// Unit was not specified on the output, but we specify it on the inputs so we can check homogeneity to ensure the division is valid
requirementConstraintsBuilder.withOptional(unit);
}
}
// Request value on the value and parent
final ValueProperties requirementConstraints = requirementConstraintsBuilder.get();
return ImmutableSet.of(new ValueRequirement(inputValue, getValueTarget(target), requirementConstraints), new ValueRequirement(inputValue, getParentTarget(target), requirementConstraints));
}