final Set<String> adjustValues = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY);
final Set<String> ageLimitValues = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY);
if (adjustValues != null && adjustValues.size() == 1 && ageLimitValues != null && ageLimitValues.size() == 1) {
return ImmutableSet.of();
}
final Builder constraints = desiredValue.getConstraints().copy();
if (adjustValues == null || adjustValues.isEmpty()) {
constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY)
.with(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY, "");
} else {
constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY)
.with(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY, adjustValues.iterator().next());
}
if (ageLimitValues == null || ageLimitValues.isEmpty()) {
constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY)
.with(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY, HistoricalTimeSeriesFunctionUtils.UNLIMITED_AGE_LIMIT_VALUE);
} else {
constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY)
.with(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY, ageLimitValues.iterator().next());
}
return ImmutableSet.of(new ValueRequirement(ValueRequirementNames.HISTORICAL_TIME_SERIES_LATEST, target.toSpecification(), constraints.get()));
}