/** * Combines this market data with another. * <p> * 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. * <p> * The valuation dates of the sets of market data must be the same. * * @param other the other market data * @return the combined market data */ public default MarketData combinedWith(MarketData other) { return new CombinedMarketData(this, other); }
public void test_combination() { CombinedMarketData test = new CombinedMarketData(BASE_DATA1, BASE_DATA2); assertEquals(test.getValuationDate(), VAL_DATE); assertEquals(test.containsValue(ID1), true); assertEquals(test.containsValue(ID2), true); assertEquals(test.containsValue(ID3), true); assertEquals(test.containsValue(ID5), false); assertEquals(test.getValue(ID1), VAL1); assertEquals(test.getValue(ID2), VAL2); assertEquals(test.getValue(ID3), VAL3); assertThrows(() -> test.getValue(ID5), MarketDataNotFoundException.class); assertEquals(test.findValue(ID1), Optional.of(VAL1)); assertEquals(test.findValue(ID2), Optional.of(VAL2)); assertEquals(test.findValue(ID3), Optional.of(VAL3)); assertEquals(test.findValue(ID5), Optional.empty()); assertEquals(test.getIds(), ImmutableSet.of(ID1, ID2, ID3)); assertEquals(test.findIds(ID1.getMarketDataName()), ImmutableSet.of(ID1)); assertEquals(test.findIds(ID3.getMarketDataName()), ImmutableSet.of(ID3)); assertEquals(test.findIds(ID4.getMarketDataName()), ImmutableSet.of()); assertEquals(test.getTimeSeries(ID5), TIME_SERIES); assertEquals(test.getTimeSeries(ID6), TIME_SERIES); }
/** * Creates an instance. * @param underlying1 the value of the property, not null * @param underlying2 the value of the property, not null */ CombinedMarketData( MarketData underlying1, MarketData underlying2) { JodaBeanUtils.notNull(underlying1, "underlying1"); JodaBeanUtils.notNull(underlying2, "underlying2"); this.underlying1 = underlying1; this.underlying2 = underlying2; validate(); }
public void coverage() { CombinedMarketData test = new CombinedMarketData(BASE_DATA1, BASE_DATA2); coverImmutableBean(test); CombinedMarketData test2 = new CombinedMarketData(BASE_DATA2, BASE_DATA1); coverBeanEquals(test, test2); }
public void serialization() { CombinedMarketData test = new CombinedMarketData(BASE_DATA1, BASE_DATA2); assertSerialization(test); }