Source:
public Result<ParRates> build(ParRatesId id, MarketDataLookup marketData, MarketDataConfig marketDataConfig) { String groupName = id.getCurveGroupName(); String curveName = id.getCurveName(); Optional<CurveGroupConfig> optionalGroup = marketDataConfig.get(CurveGroupConfig.class, groupName); if (!optionalGroup.isPresent()) { return Result.failure(FailureReason.MISSING_DATA, "No configuration found for curve group '{}'", groupName); } CurveGroupConfig groupConfig = optionalGroup.get(); Optional<CurveGroupEntry> optionalEntry = groupConfig.getEntry(curveName); if (!optionalEntry.isPresent()) { return Result.failure(FailureReason.MISSING_DATA, "No curve named '{}' found in group '{}'", curveName, groupName); } CurveGroupEntry entry = optionalEntry.get(); if (!(entry.getCurveConfig() instanceof InterpolatedCurveConfig)) { return Result.failure( FailureReason.MISSING_DATA, "Cannot create par rates for curve configuration of type {}, curve name '{}', curve group '{}'", entry.getCurveConfig().getClass().getName(), curveName, groupName); } InterpolatedCurveConfig curveConfig = (InterpolatedCurveConfig) entry.getCurveConfig(); Set<ObservableId> requirements = curveConfig.getNodes().stream() .flatMap(node -> node.requirements().stream()) .map(key -> key.toObservableId(id.getMarketDataFeed())) .collect(toImmutableSet()); if (!marketData.containsValues(requirements)) { Set<ObservableId> missingRequirements = requirements.stream() .filter(not(marketData::containsValue)) .collect(toImmutableSet()); return Result.failure(FailureReason.MISSING_DATA, "No market data available for '{}'", missingRequirements); } Map<ObservableId, Double> rates = marketData.getObservableValues(requirements); ParRates parRates = ParRates.builder().rates(rates).build(); return Result.success(parRates); }

Target:
public Result<ParRates> build(ParRatesId id, MarketDataLookup marketData, MarketDataConfig marketDataConfig) { String groupName = id.getCurveGroupName(); String curveName = id.getCurveName(); Optional<CurveGroupConfig> optionalGroup = marketDataConfig.get(CurveGroupConfig.class, groupName); if (!optionalGroup.isPresent()) { return Result.failure(FailureReason.MISSING_DATA, "No configuration found for curve group '{}'", groupName); } CurveGroupConfig groupConfig = optionalGroup.get(); Optional<CurveGroupEntry> optionalEntry = groupConfig.getEntry(curveName); if (!optionalEntry.isPresent()) { return Result.failure(FailureReason.MISSING_DATA, "No curve named '{}' found in group '{}'", curveName, groupName); } CurveGroupEntry entry = optionalEntry.get(); if (!(entry.getCurveConfig() instanceof InterpolatedCurveConfig)) { return Result.failure( FailureReason.MISSING_DATA, "Cannot create par rates for curve configuration of type {}, curve name '{}', curve group '{}'", entry.getCurveConfig().getClass().getName(), curveName, groupName); } InterpolatedCurveConfig curveConfig = (InterpolatedCurveConfig) entry.getCurveConfig(); Set<ObservableId> requirements = nodeRequirements(id.getMarketDataFeed(), curveConfig); if (!marketData.containsValues(requirements)) { Set<ObservableId> missingRequirements = requirements.stream() .filter(not(marketData::containsValue)) .collect(toImmutableSet()); return Result.failure(FailureReason.MISSING_DATA, "No market data available for '{}'", missingRequirements); } Map<ObservableId, Double> rates = marketData.getObservableValues(requirements); ParRates parRates = ParRates.of(rates); return Result.success(parRates); }