}
@Override
public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
final UnorderedCurrencyPair currencyPair = (UnorderedCurrencyPair) target.getValue();
final ValueProperties constraints = desiredValue.getConstraints();
final Set<String> curveNames = constraints.getValues(ValuePropertyNames.CURVE);
if (curveNames == null || curveNames.size() != 1) {
return null;
}
final String curveName = Iterables.getOnlyElement(curveNames);
final Set<String> curveCalculationConfigNames = constraints.getValues(ValuePropertyNames.CURVE_CALCULATION_CONFIG);
if (curveCalculationConfigNames == null || curveCalculationConfigNames.size() != 1) {
return null;
}
final String curveCalculationConfigName = Iterables.getOnlyElement(curveCalculationConfigNames);
final String ychtsStart = getFCHTSStart(constraints);
if (ychtsStart == null) {
return null;
}
final DateConstraint start = DateConstraint.parse(ychtsStart);
final String returnSeriesEnd = getReturnSeriesEnd(constraints);
if (returnSeriesEnd == null) {
return null;
}
final DateConstraint end = DateConstraint.parse(returnSeriesEnd);
if (start == null || end == null) {
return null;
}
final Set<String> includeStarts = constraints.getValues(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY);
if (includeStarts != null && includeStarts.size() != 1) {
return null;
}
final boolean includeStart = includeStarts == null ? true : HistoricalTimeSeriesFunctionUtils.YES_VALUE.equals(Iterables.getOnlyElement(includeStarts));
final Set<String> includeEnds = constraints.getValues(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY);
if (includeEnds != null && includeEnds.size() != 1) {
return null;
}
final boolean includeEnd = includeEnds == null ? false : HistoricalTimeSeriesFunctionUtils.YES_VALUE.equals(Iterables.getOnlyElement(includeEnds));
final Set<String> samplingMethod = constraints.getValues(ValuePropertyNames.SAMPLING_FUNCTION);
if (samplingMethod == null || samplingMethod.size() != 1) {
return null;
}
final Set<String> scheduleMethod = constraints.getValues(ValuePropertyNames.SCHEDULE_CALCULATOR);
if (scheduleMethod == null || scheduleMethod.size() != 1) {
return null;
}
final Set<ValueRequirement> requirements = new HashSet<ValueRequirement>();
requirements.add(HistoricalTimeSeriesFunctionUtils.createFXForwardCurveHTSRequirement(currencyPair, curveName, MarketDataRequirementNames.MARKET_VALUE,