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 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 using with 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 value
        value - the value
        Returns:
        the instance
      • 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
      • 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 interface Attributes
        Type Parameters:
        T - the type of the attribute value
        Parameters:
        type - the type providing meaning to the value
        value - 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 interface Attributes
        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