class CurveMarketDataFunction implements MarketDataFunction<Curve, CurveId> {

  @Override
  public MarketDataBox<Curve> build(
      CurveId id,
      MarketDataConfig config,
      ScenarioMarketData marketData,
      ReferenceData refData) {

    // find curve
    CurveGroupDefinition groupDefn = config.get(CurveGroupDefinition.class, id.getCurveGroupName());
    MarketDataId<? extends CurveGroup> groupId = groupDefn.createGroupId(id.getObservableSource());
    MarketDataBox<? extends CurveGroup> curveGroupBox = marketData.getValue(groupId);
    return curveGroupBox.map(curveGroup -> findCurve(id, curveGroup));
  }

}