Class SecurityInfo

  • All Implemented Interfaces:
    Attributes, java.io.Serializable, Bean, ImmutableBean

    public final class SecurityInfo
    extends java.lang.Object
    implements Attributes, ImmutableBean, java.io.Serializable
    Information about a security.

    This provides common information about a security. This includes the identifier, information about the price and an extensible data map.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static SecurityInfo of​(SecurityId id,
                                      double tickSize,
                                      CurrencyAmount tickValue)
        Obtains an instance from the identifier, tick size and tick value.

        This creates an instance, building the SecurityPriceInfo from the tick size and tick value, setting the contract size to 1.

        A SecurityInfo also contains a hash map of additional information, keyed by AttributeType. This hash map may contain anything of interest, and is populated using withAttribute(AttributeType, Object).

        Parameters:
        id - the security identifier
        tickSize - the size of each tick, not negative or zero
        tickValue - the value of each tick
        Returns:
        the security information
      • of

        public static SecurityInfo of​(SecurityId id,
                                      SecurityPriceInfo priceInfo)
        Obtains an instance from the identifier and pricing info.

        A SecurityInfo also contains a hash map of additional information, keyed by AttributeType. This hash map may contain anything of interest, and is populated using withAttribute(AttributeType, Object).

        Parameters:
        id - the security identifier
        priceInfo - the information about the price
        Returns:
        the security information
      • builder

        public static SecurityInfoBuilder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • getAttribute

        public <T> T getAttribute​(AttributeType<T> type)
        Gets the attribute associated with the specified type.

        This method obtains the specified attribute. This allows an attribute about a security to be obtained if available.

        If the attribute is not found, an exception is thrown.

        Specified by:
        getAttribute in interface Attributes
        Type Parameters:
        T - the type of the result
        Parameters:
        type - the type to find
        Returns:
        the attribute value
        Throws:
        java.lang.IllegalArgumentException - if the attribute is not found
      • findAttribute

        public <T> java.util.Optional<T> findAttribute​(AttributeType<T> type)
        Finds the attribute associated with the specified type.

        This method obtains the specified attribute. This allows an attribute about a security 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
        Parameters:
        type - the type to find
        Returns:
        the attribute value
      • withAttribute

        public <T> SecurityInfo withAttribute​(AttributeType<T> type,
                                              T value)
        Returns a copy of this instance with 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 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
      • toBuilder

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

        public static SecurityInfo.Meta meta()
        The meta-bean for SecurityInfo.
        Returns:
        the meta-bean, not null
      • getId

        public SecurityId getId()
        Gets the security identifier.

        This identifier uniquely identifies the security within the system. It is the key used to lookup the security in ReferenceData.

        A real-world security will typically have multiple identifiers. The only restriction placed on the identifier is that it is sufficiently unique for the reference data lookup. As such, it is acceptable to use an identifier from a well-known global or vendor symbology.

        Returns:
        the value of the property, not null
      • getPriceInfo

        public SecurityPriceInfo getPriceInfo()
        Gets the information about the security price.

        This provides information about the security price. This can be used to convert the price into a monetary value.

        Returns:
        the value of the property, not null
      • getAttributes

        public com.google.common.collect.ImmutableMap<AttributeType<?>,​java.lang.Object> getAttributes()
        Gets the security attributes.

        Security attributes provide the ability to associate arbitrary information in a key-value map.

        Returns:
        the value of the property, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object