Package gov.usgs.earthquake.product
Class ProductId
- java.lang.Object
-
- gov.usgs.earthquake.product.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
sourceandtype. Source and Type are effectively a namespace for codes. If the samecodeis 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
sourceandtypewith the samecodeare considered different versions of the same product. More recent (newer)updateTimes supersede less recent (older)updateTimes.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ProductId that)Implement the Comparable interface.booleanequals(java.lang.Object obj)Override the default Object.equals().java.lang.StringgetCode()java.lang.StringgetSource()java.lang.StringgetType()java.util.DategetUpdateTime()inthashCode()Override default Object.hashCode().booleanisSameProduct(ProductId that)Whether these are the same product, even if they are different versions.static ProductIdparse(java.lang.String str)Parse a product id string.voidsetCode(java.lang.String code)voidsetSource(java.lang.String source)voidsetType(java.lang.String type)voidsetUpdateTime(java.util.Date updateTime)java.lang.StringtoString()Convert this product id to a string.
-
-
-
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:
toStringin classjava.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:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(ProductId that)
Implement the Comparable interface.- Specified by:
compareToin interfacejava.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:
hashCodein classjava.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.
-
-