Interface PortfolioItemInfo
-
- All Superinterfaces:
Attributes
- All Known Implementing Classes:
PositionInfo
,TradeInfo
public interface PortfolioItemInfo extends Attributes
Additional information about a portfolio item.This allows additional information to be associated with an item. It is kept in a separate object as the information is generally optional for pricing.
Implementations of this interface must be immutable beans.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static PortfolioItemInfoBuilder<PortfolioItemInfo>
builder()
Returns a builder used to create an instance of the bean.default PortfolioItemInfo
combinedWith(PortfolioItemInfo other)
Combines this info with another.static PortfolioItemInfo
empty()
Obtains an empty info instance.ImmutableSet<AttributeType<?>>
getAttributeTypes()
Gets the attribute types that are available.Optional<StandardId>
getId()
Gets the primary identifier for the portfolio item, optional.static <T> PortfolioItemInfo
of(AttributeType<T> type, T value)
Obtains an instance with a single attribute.default PortfolioItemInfo
overrideWith(PortfolioItemInfo other)
Overrides attributes of this info with another.<T> PortfolioItemInfo
withAttribute(AttributeType<T> type, T value)
Returns a copy of this instance with the attribute added.default PortfolioItemInfo
withAttributes(Attributes other)
Returns a copy of this instance with the attributes added.PortfolioItemInfo
withId(StandardId identifier)
Returns a copy of this instance with the identifier changed.-
Methods inherited from interface com.opengamma.strata.product.Attributes
containsAttribute, containsAttribute, findAttribute, getAttribute
-
-
-
-
Method Detail
-
empty
static PortfolioItemInfo empty()
Obtains an empty info instance.The resulting instance implements this interface and is useful for classes that extend
PortfolioItem
but are not trades or positions. The returned instance can be customized usingwith
methods.- Returns:
- the empty info instance
-
of
static <T> PortfolioItemInfo of(AttributeType<T> type, T value)
Obtains an instance with a single attribute.The
withAttribute(AttributeType, Object)
method can be used on the instance to add more attributes.- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type providing meaning to the valuevalue
- the value- Returns:
- the instance
-
builder
static PortfolioItemInfoBuilder<PortfolioItemInfo> builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder
-
getId
Optional<StandardId> getId()
Gets the primary identifier for the portfolio item, optional.The identifier is used to identify the portfolio item. It will typically be an identifier in an external data system.
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.
- Returns:
- the identifier, optional
-
withId
PortfolioItemInfo withId(StandardId identifier)
Returns a copy of this instance with the identifier changed.This returns a new instance with the identifier changed. If the specified identifier is null, the existing identifier will be removed. If the specified identifier is non-null, it will become the identifier of the resulting info.
- Parameters:
identifier
- the identifier to set- Returns:
- a new instance based on this one with the identifier set
-
getAttributeTypes
ImmutableSet<AttributeType<?>> getAttributeTypes()
Description copied from interface:Attributes
Gets the attribute types that are available.See
AttributeType.captureWildcard()
for a way to capture the wildcard type.The default implementation returns an empty set (backwards compatibility prevents an abstract method for now).
- Specified by:
getAttributeTypes
in interfaceAttributes
- Returns:
- the attribute types
-
withAttribute
<T> PortfolioItemInfo withAttribute(AttributeType<T> type, T value)
Description copied from interface:Attributes
Returns a copy of this instance with the attribute added.This returns a new instance with the specified attribute added. The attribute is added using
Map.put(type, value)
semantics.- Specified by:
withAttribute
in interfaceAttributes
- Type Parameters:
T
- the type of the attribute value- Parameters:
type
- the type providing meaning to the valuevalue
- the value- Returns:
- a new instance based on this one with the attribute added
-
withAttributes
default PortfolioItemInfo withAttributes(Attributes other)
Description copied from interface:Attributes
Returns a copy of this instance with the attributes added.This returns a new instance with the specified attributes added. The attributes are added using
Map.putAll(type, value)
semantics.- Specified by:
withAttributes
in interfaceAttributes
- Parameters:
other
- the other instance to copy from- Returns:
- an instance based on this one with the attributes from the other instance
-
combinedWith
default PortfolioItemInfo combinedWith(PortfolioItemInfo other)
Combines this info with another.If there is a conflict, data from this instance takes precedence. If the other instance is not of the same type, data may be lost.
- Parameters:
other
- the other instance- Returns:
- the combined instance
-
overrideWith
default PortfolioItemInfo overrideWith(PortfolioItemInfo other)
Overrides attributes of this info with another.If there is a conflict, data from the other instance takes precedence. If the other instance is not of the same type, data may be lost.
- Parameters:
other
- the other instance- Returns:
- the combined instance
-
-