Class ProductId

  • All Implemented Interfaces:
    java.lang.Comparable<ProductId>

    public class ProductId
    extends java.lang.Object
    implements java.lang.Comparable<ProductId>
    Attributes that uniquely identify a product.
    Source
    The organization sending the product; not necessarily the author of the product. Typically a FDSN network code.
    Type
    The type of product being sent.
    Code
    A unique code assigned by the source and type. Source and Type are effectively a namespace for codes. If the same code is re-used, it indicates a different version of the same product.
    Update Time
    A timestamp representing when a product was created. Update Time is also used as a version. Products from the same source and type with the same code are considered different versions of the same product. More recent (newer) updateTimes supersede less recent (older) updateTimes.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProductId​(java.lang.String source, java.lang.String type, java.lang.String code)
      Create a new ProductId.
      ProductId​(java.lang.String source, java.lang.String type, java.lang.String code, java.util.Date updateTime)
      Create a new ProductId.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(ProductId that)
      Implement the Comparable interface.
      boolean equals​(java.lang.Object obj)
      Override the default Object.equals().
      java.lang.String getCode()  
      java.lang.String getSource()  
      java.lang.String getType()  
      java.util.Date getUpdateTime()  
      int hashCode()
      Override default Object.hashCode().
      boolean isSameProduct​(ProductId that)
      Whether these are the same product, even if they are different versions.
      static ProductId parse​(java.lang.String str)
      Parse a product id string.
      void setCode​(java.lang.String code)  
      void setSource​(java.lang.String source)  
      void setType​(java.lang.String type)  
      void setUpdateTime​(java.util.Date updateTime)  
      java.lang.String toString()
      Convert this product id to a string.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ProductId

        public ProductId​(java.lang.String source,
                         java.lang.String type,
                         java.lang.String code)
        Create a new ProductId. Same as new ProductId(type, code, source, new Date()).
        Parameters:
        source - the product source.
        type - the product type.
        code - the product code.
      • ProductId

        public ProductId​(java.lang.String source,
                         java.lang.String type,
                         java.lang.String code,
                         java.util.Date updateTime)
        Create a new ProductId.
        Parameters:
        source - the product source.
        type - the product type.
        code - the product code.
        updateTime - when the product was updated.
    • Method Detail

      • getSource

        public java.lang.String getSource()
        Returns:
        the source
      • setSource

        public void setSource​(java.lang.String source)
        Parameters:
        source - the source to set
      • getType

        public java.lang.String getType()
        Returns:
        the type
      • setType

        public void setType​(java.lang.String type)
        Parameters:
        type - the type to set
      • getCode

        public java.lang.String getCode()
        Returns:
        the code
      • setCode

        public void setCode​(java.lang.String code)
        Parameters:
        code - the code to set
      • getUpdateTime

        public java.util.Date getUpdateTime()
        Returns:
        the updateTime
      • setUpdateTime

        public void setUpdateTime​(java.util.Date updateTime)
        Parameters:
        updateTime - the updateTime to set
      • toString

        public java.lang.String toString()
        Convert this product id to a string. This string does not include the update time.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a product id string.
      • parse

        public static ProductId parse​(java.lang.String str)
        Parse a product id string.
        Parameters:
        str - a valid product id string.
        Returns:
        a ProductId object.
      • equals

        public boolean equals​(java.lang.Object obj)
        Override the default Object.equals().
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(ProductId that)
        Implement the Comparable interface.
        Specified by:
        compareTo in interface java.lang.Comparable<ProductId>
        Parameters:
        that - product id being compared.
        Returns:
        -1 if this precedes that, 0 if same, and 1 if that precedes this.
      • hashCode

        public int hashCode()
        Override default Object.hashCode().
        Overrides:
        hashCode in class java.lang.Object
      • isSameProduct

        public boolean isSameProduct​(ProductId that)
        Whether these are the same product, even if they are different versions. It is possible for isSameProduct to return true if equals returns false, but if equals returns true isSameProduct will also return true.
        Parameters:
        that - a ProductId to test.
        Returns:
        true if these are the same product (source,type,code), false otherwise.