Class 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
    • Method Detail

      • empty

        public static PositionInfo empty()
        Obtains an empty instance, with no identifier or attributes.
        the empty instance
      • of

        public static PositionInfo of​(StandardId positionId)
        Obtains an instance with the specified position identifier.
        positionId - the position identifier
        the position information
      • builder

        public static PositionInfoBuilder builder()
        Returns a builder used to create an instance of the bean.
        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 interface PortfolioItemInfo
        identifier - the identifier to set
        a new instance based on this one with the identifier set
      • 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 interface Attributes
        Type Parameters:
        T - the type of the result
        type - the type to find
        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 interface Attributes
        Specified by:
        withAttribute in interface PortfolioItemInfo
        Type Parameters:
        T - the type of the attribute value
        type - the type providing meaning to the value
        value - the value
        a new instance based on this one with the attribute added
      • toBuilder

        public PositionInfoBuilder toBuilder()
        Returns a builder populated with the values of this instance.
        a builder populated with the values of this instance
      • meta

        public static PositionInfo.Meta meta()
        The meta-bean for PositionInfo.
        the meta-bean, not null
      • metaBean

        public PositionInfo.Meta metaBean()
        Specified by:
        metaBean in interface org.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 interface PortfolioItemInfo
        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.

        the value of the property, not null
      • hashCode

        public int hashCode()
        hashCode in class Object