Class ImmutableMarketData
- java.lang.Object
-
- com.opengamma.strata.data.ImmutableMarketData
-
- All Implemented Interfaces:
MarketData
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class ImmutableMarketData extends Object implements MarketData, org.joda.beans.ImmutableBean, Serializable
An immutable set of market dataThis is the standard immutable implementation of
MarketData
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableMarketData.Meta
The meta-bean forImmutableMarketData
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableMarketDataBuilder
builder(LocalDate valuationDate)
Creates a builder that can be used to build an instance ofMarketData
.ImmutableMarketData
combinedWith(ImmutableMarketData other)
Combines this set of market data with another.MarketData
combinedWith(MarketData other)
Combines this market data with another.boolean
containsValue(MarketDataId<?> id)
Checks if this market data contains a value for the specified identifier.boolean
equals(Object obj)
<T> Set<MarketDataId<T>>
findIds(MarketDataName<T> name)
Finds the market data identifiers associated with the specified name.<T> Optional<T>
findValue(MarketDataId<T> id)
Finds the market data value associated with the specified identifier.Set<MarketDataId<?>>
getIds()
Gets the market data identifiers.ImmutableMap<ObservableId,LocalDateDoubleTimeSeries>
getTimeSeries()
Gets the time-series.LocalDateDoubleTimeSeries
getTimeSeries(ObservableId id)
Gets the time-series identified by the specified identifier, empty if not found.Set<ObservableId>
getTimeSeriesIds()
Gets the time-series identifiers.LocalDate
getValuationDate()
Gets the valuation date associated with the market data.<T> T
getValue(MarketDataId<T> id)
Gets the market data value associated with the specified identifier.ImmutableMap<MarketDataId<?>,Object>
getValues()
Gets the market data values.int
hashCode()
static ImmutableMarketData.Meta
meta()
The meta-bean forImmutableMarketData
.ImmutableMarketData.Meta
metaBean()
static ImmutableMarketData
of(LocalDate valuationDate, Map<? extends MarketDataId<?>,?> values)
Obtains an instance from a valuation date and map of values.ImmutableMarketDataBuilder
toBuilder()
Returns a builder populated with the same data as this instance.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.data.MarketData
withValue
-
-
-
-
Method Detail
-
of
public static ImmutableMarketData of(LocalDate valuationDate, Map<? extends MarketDataId<?>,?> values)
Obtains an instance from a valuation date and map of values.Use the builder for more more complex use cases, including setting time-series.
- Parameters:
valuationDate
- the valuation date associated with the market datavalues
- the market data values- Returns:
- a set of market data containing the values in the map
- Throws:
ClassCastException
- if a value does not match the parameterized type associated with the identifier
-
builder
public static ImmutableMarketDataBuilder builder(LocalDate valuationDate)
Creates a builder that can be used to build an instance ofMarketData
.- Parameters:
valuationDate
- the valuation date- Returns:
- the builder, not null
-
toBuilder
public ImmutableMarketDataBuilder toBuilder()
Returns a builder populated with the same data as this instance.- Returns:
- the mutable builder, not null
-
containsValue
public boolean containsValue(MarketDataId<?> id)
Description copied from interface:MarketData
Checks if this market data contains a value for the specified identifier.- Specified by:
containsValue
in interfaceMarketData
- Parameters:
id
- the identifier to find- Returns:
- true if the market data contains a value for the identifier
-
combinedWith
public ImmutableMarketData combinedWith(ImmutableMarketData other)
Combines this set of market data with another.The result combines both sets of market data. Values are taken from this set of market data if available, otherwise they are taken from the other set.
The valuation dates of the sets of market data must be the same.
- Parameters:
other
- the other market data- Returns:
- the combined market data
-
combinedWith
public MarketData combinedWith(MarketData other)
Description copied from interface:MarketData
Combines this market data with another.The result combines both sets of market data. Values are taken from this set of market data if available, otherwise they are taken from the other set.
The valuation dates of the sets of market data must be the same.
- Specified by:
combinedWith
in interfaceMarketData
- Parameters:
other
- the other market data- Returns:
- the combined market data
-
getValue
public <T> T getValue(MarketDataId<T> id)
Description copied from interface:MarketData
Gets the market data value associated with the specified identifier.If this market data instance contains the identifier, the value will be returned. Otherwise, an exception will be thrown.
- Specified by:
getValue
in interfaceMarketData
- Type Parameters:
T
- the type of the market data value- Parameters:
id
- the identifier to find- Returns:
- the market data value
-
findValue
public <T> Optional<T> findValue(MarketDataId<T> id)
Description copied from interface:MarketData
Finds the market data value associated with the specified identifier.If this market data instance contains the identifier, the value will be returned. Otherwise, an empty optional will be returned.
- Specified by:
findValue
in interfaceMarketData
- Type Parameters:
T
- the type of the market data value- Parameters:
id
- the identifier to find- Returns:
- the market data value, empty if not found
-
getIds
public Set<MarketDataId<?>> getIds()
Description copied from interface:MarketData
Gets the market data identifiers.- Specified by:
getIds
in interfaceMarketData
- Returns:
- the set of market data identifiers
-
findIds
public <T> Set<MarketDataId<T>> findIds(MarketDataName<T> name)
Description copied from interface:MarketData
Finds the market data identifiers associated with the specified name.This returns the unique identifiers that refer to the specified name. There may be more than one identifier associated with a name as the name is not unique.
- Specified by:
findIds
in interfaceMarketData
- Type Parameters:
T
- the type of the market data value- Parameters:
name
- the name to find- Returns:
- the set of market data identifiers, empty if name not found
-
getTimeSeriesIds
public Set<ObservableId> getTimeSeriesIds()
Description copied from interface:MarketData
Gets the time-series identifiers.- Specified by:
getTimeSeriesIds
in interfaceMarketData
- Returns:
- the set of observable identifiers
-
getTimeSeries
public LocalDateDoubleTimeSeries getTimeSeries(ObservableId id)
Description copied from interface:MarketData
Gets the time-series identified by the specified identifier, empty if not found.- Specified by:
getTimeSeries
in interfaceMarketData
- Parameters:
id
- the identifier to find- Returns:
- the time-series, empty if no time-series found
-
meta
public static ImmutableMarketData.Meta meta()
The meta-bean forImmutableMarketData
.- Returns:
- the meta-bean, not null
-
metaBean
public ImmutableMarketData.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getValuationDate
public LocalDate getValuationDate()
Gets the valuation date associated with the market data.- Specified by:
getValuationDate
in interfaceMarketData
- Returns:
- the value of the property, not null
-
getValues
public ImmutableMap<MarketDataId<?>,Object> getValues()
Gets the market data values.- Returns:
- the value of the property, not null
-
getTimeSeries
public ImmutableMap<ObservableId,LocalDateDoubleTimeSeries> getTimeSeries()
Gets the time-series.If a request is made for a time-series that is not in the map, an empty series will be returned.
- Returns:
- the value of the property, not null
-
-