Class ProductId

java.lang.Object
gov.usgs.earthquake.product.ProductId
All Implemented Interfaces:
Comparable<ProductId>

public class ProductId extends Object implements 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 Details

    • ProductId

      public ProductId(String source, String type, 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(String source, String type, String code, 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 Details

    • fromJson

      public static ProductId fromJson(javax.json.JsonObject jsonObject) throws InvalidProductIdException
      Create a new ProductId from JsonObject
      Parameters:
      jsonObject - JsonObject that contains source/type/code/updateTime fields of a productId.
      Returns:
      The parsed out ProductId
      Throws:
      InvalidProductIdException - when the source/type/code are not present
    • getSource

      public String getSource()
      Returns:
      the source
    • setSource

      public void setSource(String source)
      Parameters:
      source - the source to set
    • getType

      public String getType()
      Returns:
      the type
    • setType

      public void setType(String type)
      Parameters:
      type - the type to set
    • getCode

      public String getCode()
      Returns:
      the code
    • setCode

      public void setCode(String code)
      Parameters:
      code - the code to set
    • getUpdateTime

      public Date getUpdateTime()
      Returns:
      the updateTime
    • setUpdateTime

      public void setUpdateTime(Date updateTime)
      Parameters:
      updateTime - the updateTime to set
    • toString

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

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

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

      public int compareTo(ProductId that)
      Implement the Comparable interface.
      Specified by:
      compareTo in interface 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 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.