Interface ReferenceData

  • All Known Implementing Classes:
    ImmutableReferenceData

    public interface ReferenceData
    Provides access to reference data, such as holiday calendars and securities.

    Reference data is looked up using implementations of ReferenceDataId. The identifier is parameterized with the type of the reference data to be returned.

    The standard implementation is ImmutableReferenceData.

    • Method Detail

      • of

        static ReferenceData of​(java.util.Map<? extends ReferenceDataId<?>,​?> values)
        Obtains an instance from a map of reference data.

        Each entry in the map is a single piece of reference data, keyed by the matching identifier. For example, a HolidayCalendar can be looked up using a HolidayCalendarId. The caller must ensure that the each entry in the map corresponds with the parameterized type on the identifier.

        The resulting ReferenceData instance will include the minimal set of reference data that includes non-controversial identifiers that are essential for pricing. To exclude the minimal set of identifiers, use ImmutableReferenceData.of(Map).

        Parameters:
        values - the reference data values
        Returns:
        the reference data instance containing the values in the map
        Throws:
        java.lang.ClassCastException - if a value does not match the parameterized type associated with the identifier
      • standard

        static ReferenceData standard()
        Obtains an instance of standard reference data.

        Standard reference data is built into Strata and provides common holiday calendars and indices. In most cases, production usage of Strata will not rely on this source of reference data.

        Returns:
        standard reference data
      • empty

        static ReferenceData empty()
        Obtains an instance containing no reference data.
        Returns:
        empty reference data
      • containsValue

        default boolean containsValue​(ReferenceDataId<?> id)
        Checks if this reference data contains a value for the specified identifier.
        Parameters:
        id - the identifier to find
        Returns:
        true if the reference data contains a value for the identifier
      • getValue

        default <T> T getValue​(ReferenceDataId<T> id)
        Gets the reference data value associated with the specified identifier.

        If this reference data instance contains the identifier, the value will be returned. Otherwise, an exception will be thrown.

        Type Parameters:
        T - the type of the reference data value
        Parameters:
        id - the identifier to find
        Returns:
        the reference data value
        Throws:
        ReferenceDataNotFoundException - if the identifier is not found
      • findValue

        default <T> java.util.Optional<T> findValue​(ReferenceDataId<T> id)
        Finds the reference data value associated with the specified identifier.

        If this reference data instance contains the identifier, the value will be returned. Otherwise, an empty optional will be returned.

        Type Parameters:
        T - the type of the reference data value
        Parameters:
        id - the identifier to find
        Returns:
        the reference data value, empty if not found
      • queryValueOrNull

        <T> T queryValueOrNull​(ReferenceDataId<T> id)
        Low-level method to query the reference data value associated with the specified identifier, returning null if not found.

        This is a low-level method that obtains the reference data value, returning null instead of an error. Applications should use getValue(ReferenceDataId) in preference to this method.

        Type Parameters:
        T - the type of the reference data value
        Parameters:
        id - the identifier to find
        Returns:
        the reference data value, null if not found
      • combinedWith

        default ReferenceData combinedWith​(ReferenceData other)
        Combines this reference data with another.

        The result combines both sets of reference data. Values are taken from this set of reference data if available, otherwise they are taken from the other set.

        Parameters:
        other - the other reference data
        Returns:
        the combined reference data