}
@Override
public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
ValueProperties.Builder constraints = null;
final ValueProperties desiredValueConstraints = desiredValue.getConstraints();
final Set<String> curveNames = desiredValueConstraints.getValues(CURVE);
if (curveNames == null || curveNames.size() != 1) {
return null;
}
Set<String> values = desiredValueConstraints.getValues(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY);
if ((values == null) || values.isEmpty()) {
constraints = desiredValueConstraints.copy().with(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY, MarketDataRequirementNames.MARKET_VALUE);
} else if (values.size() > 1) {
constraints = desiredValueConstraints.copy().withoutAny(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY)
.with(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY, values.iterator().next());
}
values = desiredValueConstraints.getValues(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY);
if ((values == null) || values.isEmpty()) {
if (constraints == null) {
constraints = desiredValueConstraints.copy();
}
constraints.with(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY, "");
} else if (values.size() > 1) {
if (constraints == null) {
constraints = desiredValueConstraints.copy();
}
constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY).with(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY, values.iterator().next());
}
values = desiredValueConstraints.getValues(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY);
if ((values == null) || values.isEmpty()) {
if (constraints == null) {
constraints = desiredValueConstraints.copy();
}
constraints.with(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY, "");
}
values = desiredValueConstraints.getValues(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY);
if ((values == null) || (values.size() != 1)) {
if (constraints == null) {
constraints = desiredValueConstraints.copy();
}
constraints.with(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY, HistoricalTimeSeriesFunctionUtils.YES_VALUE);
}
values = desiredValueConstraints.getValues(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY);
if ((values == null) || values.isEmpty()) {
if (constraints == null) {
constraints = desiredValueConstraints.copy();
}
constraints.with(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY, "");
}
values = desiredValueConstraints.getValues(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY);
if ((values == null) || (values.size() != 1)) {
if (constraints == null) {
constraints = desiredValueConstraints.copy();
}
constraints.with(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY, HistoricalTimeSeriesFunctionUtils.YES_VALUE);
}
return Collections.emptySet();
}