<commit_before>/**
 * Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.strata.basics.market;

import java.time.LocalDate;
import java.util.Map;
import java.util.Optional;

import com.opengamma.strata.collect.timeseries.LocalDateDoubleTimeSeries;

/**
 * Provides access to market data, such as curves, surfaces and time-series.
 * <p>
 * Market data is looked up using subclasses of {@link MarketDataKey}.
 * All data is valid for a single date, defined by {@link #getValuationDate()}.
 * When performing calculations with scenarios, only the data of a single scenario is accessible.
 * <p>
 * The standard implementation is {@link ImmutableMarketData}.
 */
public interface MarketData {

  /**
   * Obtains an instance from a valuation date and map of values.
   *
   * @param valuationDate  the valuation date associated with the market data
   * @param values  the market data values
   * @return a set of market data containing the values in the map
   */
  public static MarketData of(LocalDate valuationDate, Map<? extends MarketDataKey<?>, ?> values) {
    return ImmutableMarketData.of(valuationDate, values);
  }

  /**
   * Obtains an instance from a valuation date, map of values and time-series.
   *
   * @param valuationDate  the valuation date associated with the market data
   * @param values  the market data values
   * @param timeSeries  the time-series
   * @return a set of market data containing the values and time-series
   */
  public static MarketData of(
      LocalDate valuationDate,
      Map<? extends MarketDataKey<?>, ?> values,
      Map<? extends ObservableKey, LocalDateDoubleTimeSeries> timeSeries) {

    return ImmutableMarketData.builder(valuationDate).values(values).timeSeries(timeSeries).build();
  }

  //-------------------------------------------------------------------------
  /**
   * Gets the valuation date of the market data.
   * <p>
   * All values accessible through this interface have the same valuation date.
   * 
   * @return the valuation date
   */
  public abstract LocalDate getValuationDate();

  //-------------------------------------------------------------------------
  /**
   * Returns a box containing values for the specified ID if available.
   *
   * @param key  the key identifying the item of market data
   * @return a box containing values for the specified ID if available
   */
  public abstract <T> Optional<T> findValue(MarketDataKey<T> key);

  /**
   * Gets the market data value identified by the specified key.
   * <p>
   * The result will be a single piece of market data valid for the valuation date.
   *
   * @param <T>  the type of the market data<commit_msg>Fix Javadoc<commit_after>/**
 * Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.strata.basics.market;

import java.time.LocalDate;
import java.util.Map;
import java.util.Optional;

import com.opengamma.strata.collect.timeseries.LocalDateDoubleTimeSeries;

/**
 * Provides access to market data, such as curves, surfaces and time-series.
 * <p>
 * Market data is looked up using subclasses of {@link MarketDataKey}.
 * All data is valid for a single date, defined by {@link #getValuationDate()}.
 * When performing calculations with scenarios, only the data of a single scenario is accessible.
 * <p>
 * The standard implementation is {@link ImmutableMarketData}.
 */
public interface MarketData {

  /**
   * Obtains an instance from a valuation date and map of values.
   *
   * @param valuationDate  the valuation date associated with the market data
   * @param values  the market data values
   * @return a set of market data containing the values in the map
   */
  public static MarketData of(LocalDate valuationDate, Map<? extends MarketDataKey<?>, ?> values) {
    return ImmutableMarketData.of(valuationDate, values);
  }

  /**
   * Obtains an instance from a valuation date, map of values and time-series.
   *
   * @param valuationDate  the valuation date associated with the market data
   * @param values  the market data values
   * @param timeSeries  the time-series
   * @return a set of market data containing the values and time-series
   */
  public static MarketData of(
      LocalDate valuationDate,
      Map<? extends MarketDataKey<?>, ?> values,
      Map<? extends ObservableKey, LocalDateDoubleTimeSeries> timeSeries) {

    return ImmutableMarketData.builder(valuationDate).values(values).timeSeries(timeSeries).build();
  }

  //-------------------------------------------------------------------------
  /**
   * Gets the valuation date of the market data.
   * <p>
   * All values accessible through this interface have the same valuation date.
   * 
   * @return the valuation date
   */
  public abstract LocalDate getValuationDate();

  //-------------------------------------------------------------------------
  /**
   * Returns a value for the specified ID if available.
   *
   * @param key  the key identifying the item of market data
   * @return a value for the specified ID if available
   */
  public abstract <T> Optional<T> findValue(MarketDataKey<T> key);

  /**
   * Gets the market data value identified by the specified key.
   * <p>
   * The result will be a single piece of market data valid for the valuation date.
   *
   * @param <T>  the type of the market data
{'fraction_non_alphanumeric': 0.13211678832116788, 'fraction_numerical': 0.00145985401459854, 'mean_word_length': 2.7904564315352696, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6544194', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1391, 'n_words': 592}