Class TradeInfo
- java.lang.Object
-
- com.opengamma.strata.product.TradeInfo
-
- All Implemented Interfaces:
Attributes,PortfolioItemInfo,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class TradeInfo extends Object implements PortfolioItemInfo, org.joda.beans.ImmutableBean, Serializable
Additional information about a trade.This allows additional information about a trade 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 classTradeInfo.MetaThe meta-bean forTradeInfo.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TradeInfoBuilderbuilder()Returns a builder used to create an instance of the bean.TradeInfocombinedWith(PortfolioItemInfo other)Combines this info with another.static TradeInfoempty()Obtains an empty instance, with no values or attributes.booleanequals(Object obj)<T> Optional<T>findAttribute(AttributeType<T> type)Finds the attribute associated with the specified type.static TradeInfofrom(PortfolioItemInfo info)Obtains an instance based on the supplied info.ImmutableMap<AttributeType<?>,Object>getAttributes()Gets the trade attributes.ImmutableSet<AttributeType<?>>getAttributeTypes()Gets the attribute types that are available.Optional<StandardId>getCounterparty()Gets the counterparty identifier, optional.Optional<StandardId>getId()Gets the primary identifier for the trade, optional.Optional<LocalDate>getSettlementDate()Gets the settlement date, optional.Optional<LocalDate>getTradeDate()Gets the trade date, optional.Optional<LocalTime>getTradeTime()Gets the trade time, optional.Optional<ZoneId>getZone()Gets the trade time-zone, optional.inthashCode()static TradeInfo.Metameta()The meta-bean forTradeInfo.TradeInfo.MetametaBean()static TradeInfoof(LocalDate tradeDate)Obtains an instance with the specified trade date.TradeInfooverrideWith(PortfolioItemInfo other)Overrides attributes of this info with another.TradeInfoBuildertoBuilder()Returns a builder populated with the values of this instance.StringtoString()<T> TradeInfowithAttribute(AttributeType<T> type, T value)Returns a copy of this instance with the attribute added.TradeInfowithAttributes(Attributes other)Returns a copy of this instance with the attributes added.TradeInfowithId(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 TradeInfo empty()
Obtains an empty instance, with no values or attributes.- Returns:
- the empty instance
-
of
public static TradeInfo of(LocalDate tradeDate)
Obtains an instance with the specified trade date.- Parameters:
tradeDate- the trade date- Returns:
- the trade information
-
from
public static TradeInfo from(PortfolioItemInfo info)
Obtains an instance based on the supplied info.- Parameters:
info- the base info- Returns:
- the trade information
-
builder
public static TradeInfoBuilder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
withId
public TradeInfo withId(StandardId identifier)
Description copied from interface:PortfolioItemInfoReturns 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:
withIdin 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:AttributesGets 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:
getAttributeTypesin interfaceAttributes- Specified by:
getAttributeTypesin interfacePortfolioItemInfo- Returns:
- the attribute types
-
findAttribute
public <T> Optional<T> findAttribute(AttributeType<T> type)
Description copied from interface:AttributesFinds 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:
findAttributein interfaceAttributes- Type Parameters:
T- the type of the result- Parameters:
type- the type to find- Returns:
- the attribute value
-
withAttribute
public <T> TradeInfo withAttribute(AttributeType<T> type, T value)
Description copied from interface:AttributesReturns 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:
withAttributein interfaceAttributes- Specified by:
withAttributein 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 TradeInfo withAttributes(Attributes other)
Description copied from interface:AttributesReturns 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:
withAttributesin interfaceAttributes- Specified by:
withAttributesin 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 TradeInfo combinedWith(PortfolioItemInfo other)
Description copied from interface:PortfolioItemInfoCombines 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:
combinedWithin interfacePortfolioItemInfo- Parameters:
other- the other instance- Returns:
- the combined instance
-
overrideWith
public TradeInfo overrideWith(PortfolioItemInfo other)
Description copied from interface:PortfolioItemInfoOverrides 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:
overrideWithin interfacePortfolioItemInfo- Parameters:
other- the other instance- Returns:
- the combined instance
-
toBuilder
public TradeInfoBuilder toBuilder()
Returns a builder populated with the values of this instance.- Returns:
- a builder populated with the values of this instance
-
meta
public static TradeInfo.Meta meta()
The meta-bean forTradeInfo.- Returns:
- the meta-bean, not null
-
metaBean
public TradeInfo.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getId
public Optional<StandardId> getId()
Gets the primary identifier for the trade, optional.The identifier is used to identify the trade. It will typically be an identifier in an external data system.
A trade 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:
getIdin interfacePortfolioItemInfo- Returns:
- the optional value of the property, not null
-
getCounterparty
public Optional<StandardId> getCounterparty()
Gets the counterparty identifier, optional.An identifier used to specify the counterparty of the trade.
- Returns:
- the optional value of the property, not null
-
getTradeDate
public Optional<LocalDate> getTradeDate()
Gets the trade date, optional.- Returns:
- the optional value of the property, not null
-
getTradeTime
public Optional<LocalTime> getTradeTime()
Gets the trade time, optional.- Returns:
- the optional value of the property, not null
-
getZone
public Optional<ZoneId> getZone()
Gets the trade time-zone, optional.- Returns:
- the optional value of the property, not null
-
getSettlementDate
public Optional<LocalDate> getSettlementDate()
Gets the settlement date, optional.- Returns:
- the optional value of the property, not null
-
getAttributes
public ImmutableMap<AttributeType<?>,Object> getAttributes()
Gets the trade attributes.Trade attributes provide the ability to associate arbitrary information in a key-value map.
- Returns:
- the value of the property, not null
-
-