Class PositionInfo
- java.lang.Object
-
- com.opengamma.strata.product.PositionInfo
-
- All Implemented Interfaces:
Attributes
,PortfolioItemInfo
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class PositionInfo extends Object implements PortfolioItemInfo, org.joda.beans.ImmutableBean, Serializable
Additional information about a position.This allows additional information about a position to be associated. It is kept in a separate object as the information is optional for pricing.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PositionInfo.Meta
The meta-bean forPositionInfo
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PositionInfoBuilder
builder()
Returns a builder used to create an instance of the bean.PositionInfo
combinedWith(PortfolioItemInfo other)
Combines this info with another.static PositionInfo
empty()
Obtains an empty instance, with no identifier or attributes.boolean
equals(Object obj)
<T> Optional<T>
findAttribute(AttributeType<T> type)
Finds the attribute associated with the specified type.static PositionInfo
from(PortfolioItemInfo info)
Obtains an instance based on the supplied info.ImmutableMap<AttributeType<?>,Object>
getAttributes()
Gets the position attributes.ImmutableSet<AttributeType<?>>
getAttributeTypes()
Gets the attribute types that are available.Optional<StandardId>
getId()
Gets the primary identifier for the position, optional.int
hashCode()
static PositionInfo.Meta
meta()
The meta-bean forPositionInfo
.PositionInfo.Meta
metaBean()
static PositionInfo
of(StandardId positionId)
Obtains an instance with the specified position identifier.PositionInfo
overrideWith(PortfolioItemInfo other)
Overrides attributes of this info with another.PositionInfoBuilder
toBuilder()
Returns a builder populated with the values of this instance.String
toString()
<T> PositionInfo
withAttribute(AttributeType<T> type, T value)
Returns a copy of this instance with the attribute added.PositionInfo
withAttributes(Attributes other)
Returns a copy of this instance with the attributes added.PositionInfo
withId(StandardId identifier)
Returns a copy of this instance with the identifier changed.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.Attributes
containsAttribute, containsAttribute, getAttribute
-
-
-
-
Method Detail
-
empty
public static PositionInfo empty()
Obtains an empty instance, with no identifier or attributes.- Returns:
- the empty instance
-
of
public static PositionInfo of(StandardId positionId)
Obtains an instance with the specified position identifier.- Parameters:
positionId
- the position identifier- Returns:
- the position information
-
from
public static PositionInfo from(PortfolioItemInfo info)
Obtains an instance based on the supplied info.- Parameters:
info
- the base info- Returns:
- the position information
-
builder
public static PositionInfoBuilder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder
-
withId
public PositionInfo withId(StandardId identifier)
Description copied from interface:PortfolioItemInfo
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.
- Specified by:
withId
in interfacePortfolioItemInfo
- Parameters:
identifier
- the identifier to set- Returns:
- a new instance based on this one with the identifier set
-
getAttributeTypes
public 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
- Specified by:
getAttributeTypes
in interfacePortfolioItemInfo
- Returns:
- the attribute types
-
findAttribute
public <T> Optional<T> findAttribute(AttributeType<T> type)
Description copied from interface:Attributes
Finds the attribute associated with the specified type.This method obtains the specified attribute. This allows an attribute to be obtained if available.
If the attribute is not found, optional empty is returned.
- Specified by:
findAttribute
in interfaceAttributes
- Type Parameters:
T
- the type of the result- Parameters:
type
- the type to find- Returns:
- the attribute value
-
withAttribute
public <T> PositionInfo 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
- Specified by:
withAttribute
in interfacePortfolioItemInfo
- 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
public PositionInfo 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
- Specified by:
withAttributes
in interfacePortfolioItemInfo
- Parameters:
other
- the other instance to copy from- Returns:
- an instance based on this one with the attributes from the other instance
-
combinedWith
public PositionInfo combinedWith(PortfolioItemInfo other)
Description copied from interface:PortfolioItemInfo
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.
- Specified by:
combinedWith
in interfacePortfolioItemInfo
- Parameters:
other
- the other instance- Returns:
- the combined instance
-
overrideWith
public PositionInfo overrideWith(PortfolioItemInfo other)
Description copied from interface:PortfolioItemInfo
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.
- Specified by:
overrideWith
in interfacePortfolioItemInfo
- Parameters:
other
- the other instance- Returns:
- the combined instance
-
toBuilder
public PositionInfoBuilder toBuilder()
Returns a builder populated with the values of this instance.- Returns:
- a builder populated with the values of this instance
-
meta
public static PositionInfo.Meta meta()
The meta-bean forPositionInfo
.- Returns:
- the meta-bean, not null
-
metaBean
public PositionInfo.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getId
public Optional<StandardId> getId()
Gets the primary identifier for the position, optional.The identifier is used to identify the position. It will typically be an identifier in an external data system.
A position 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.
- Specified by:
getId
in interfacePortfolioItemInfo
- Returns:
- the optional value of the property, not null
-
getAttributes
public ImmutableMap<AttributeType<?>,Object> getAttributes()
Gets the position attributes.Position attributes provide the ability to associate arbitrary information in a key-value map.
- Returns:
- the value of the property, not null
-
-