public final class PositionInfo extends Object implements PortfolioItemInfo, org.joda.beans.ImmutableBean, Serializable
This allows additional information about a position to be associated. It is kept in a separate object as the information is optional for pricing.
| Modifier and Type | Class and Description |
|---|---|
static class |
PositionInfo.Meta
The meta-bean for
PositionInfo. |
| Modifier and Type | Method and 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 for
PositionInfo. |
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitofcontainsAttribute, containsAttribute, getAttributepublic static PositionInfo empty()
empty in interface Attributesempty in interface PortfolioItemInfopublic static PositionInfo of(StandardId positionId)
positionId - the position identifierpublic static PositionInfo from(PortfolioItemInfo info)
info - the base infopublic static PositionInfoBuilder builder()
builder in interface PortfolioItemInfopublic PositionInfo withId(StandardId identifier)
PortfolioItemInfoThis 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.
withId in interface PortfolioItemInfoidentifier - the identifier to setpublic ImmutableSet<AttributeType<?>> getAttributeTypes()
Attributes
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).
getAttributeTypes in interface AttributesgetAttributeTypes in interface PortfolioItemInfopublic <T> Optional<T> findAttribute(AttributeType<T> type)
AttributesThis method obtains the specified attribute. This allows an attribute to be obtained if available.
If the attribute is not found, optional empty is returned.
findAttribute in interface AttributesT - the type of the resulttype - the type to findpublic <T> PositionInfo withAttribute(AttributeType<T> type, T value)
Attributes
This returns a new instance with the specified attribute added.
The attribute is added using Map.put(type, value) semantics.
withAttribute in interface AttributeswithAttribute in interface PortfolioItemInfoT - the type of the attribute valuetype - the type providing meaning to the valuevalue - the valuepublic PositionInfo withAttributes(Attributes other)
Attributes
This returns a new instance with the specified attributes added.
The attributes are added using Map.putAll(type, value) semantics.
withAttributes in interface AttributeswithAttributes in interface PortfolioItemInfoother - the other instance to copy frompublic PositionInfo combinedWith(PortfolioItemInfo other)
PortfolioItemInfoIf there is a conflict, data from this instance takes precedence. If the other instance is not of the same type, data may be lost.
combinedWith in interface PortfolioItemInfoother - the other instancepublic PositionInfo overrideWith(PortfolioItemInfo other)
PortfolioItemInfoIf 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.
overrideWith in interface PortfolioItemInfoother - the other instancepublic PositionInfoBuilder toBuilder()
public static PositionInfo.Meta meta()
PositionInfo.public PositionInfo.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic Optional<StandardId> getId()
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.
getId in interface PortfolioItemInfopublic ImmutableMap<AttributeType<?>,Object> getAttributes()
Position attributes provide the ability to associate arbitrary information in a key-value map.
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.