/** * Gets the primary identifier for the portfolio item, optional. * <p> * The identifier is used to identify the portfolio item. * It will typically be an identifier in an external data system. * <p> * A portfolio item may have multiple active identifiers. Any identifier may be chosen here. * Certain uses of the identifier, such as storage in a database, require that the * identifier does not change over time, and this should be considered best practice. * * @return the identifier, optional */ public default Optional<StandardId> getId() { return getInfo().getId(); }
/** * Combines this set of sensitivities with another set. * <p> * This returns a new curve sensitivities with a combined map of typed sensitivities. * Any sensitivities of the same type will be combined as though using * {@link CurrencyParameterSensitivities#mergedWith(CurrencyParameterSensitivities)}. * The identifier and attributes of this instance will take precedence. * * @param other the other parameter sensitivities * @return an instance based on this one, with the other instance added */ @SuppressWarnings({"rawtypes", "unchecked"}) public CurveSensitivities mergedWith(CurveSensitivities other) { PortfolioItemInfo combinedInfo = info; if (!info.getId().isPresent() && other.info.getId().isPresent()) { combinedInfo = combinedInfo.withId(other.info.getId().get()); } for (AttributeType attrType : other.info.getAttributeTypes()) { if (!combinedInfo.getAttributeTypes().contains(attrType)) { combinedInfo = combinedInfo.withAttribute(attrType, other.info.getAttribute(attrType)); } } return new CurveSensitivities(combinedInfo, mergedWith(other.typedSensitivities).getTypedSensitivities()); }
public void test_withers() { PortfolioItemInfo test = PortfolioItemInfo.empty() .withId(ID) .withAttribute(AttributeType.DESCRIPTION, "A"); assertEquals(test.getId(), Optional.of(ID)); assertEquals(test.getAttributeTypes(), ImmutableSet.of(AttributeType.DESCRIPTION)); assertEquals(test.getAttribute(AttributeType.DESCRIPTION), "A"); assertEquals(test.findAttribute(AttributeType.DESCRIPTION), Optional.of("A")); assertThrows(IllegalArgumentException.class, () -> test.getAttribute(AttributeType.NAME)); }
CsvRow peekedRow = csv.peek(); PortfolioItemInfo info = parseInfo(peekedRow); String id = info.getId().map(StandardId::toString).orElse("");
CsvRow peekedRow = csv.peek(); PortfolioItemInfo info = parseInfo(peekedRow); String id = info.getId().map(StandardId::toString).orElse("");
CsvRow peekedRow = csv.peek(); PortfolioItemInfo info = parseInfo(peekedRow); String id = info.getId().map(StandardId::toString).orElse("");