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 Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ReferenceData
combinedWith(ReferenceData other)
Combines this reference data with another.default boolean
containsValue(ReferenceDataId<?> id)
Checks if this reference data contains a value for the specified identifier.static ReferenceData
empty()
Obtains an instance containing no reference data.default <T> Optional<T>
findValue(ReferenceDataId<T> id)
Finds the reference data value associated with the specified identifier.default <T> T
getValue(ReferenceDataId<T> id)
Gets the reference data value associated with the specified identifier.static ReferenceData
minimal()
Obtains the minimal set of reference data.static ReferenceData
of(Map<? extends ReferenceDataId<?>,?> values)
Obtains an instance from a map of reference data.<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.static ReferenceData
standard()
Obtains an instance of standard reference data.
-
-
-
Method Detail
-
of
static ReferenceData of(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 aHolidayCalendarId
. 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, useImmutableReferenceData.of(Map)
.- Parameters:
values
- the reference data values- Returns:
- the reference data instance containing the values in the map
- Throws:
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
-
minimal
static ReferenceData minimal()
Obtains the minimal set of reference data.The standard reference data contains common holiday calendars and indices, but may not be suitable for production use. The minimal reference data contains just those identifiers that are needed by Strata, and that are non-controversial. These are
HolidayCalendars.NO_HOLIDAYS
,HolidayCalendars.SAT_SUN
,HolidayCalendars.FRI_SAT
andHolidayCalendars.THU_FRI
.- Returns:
- minimal 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> 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
-
-