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
source
andtype
. Source and Type are effectively a namespace for codes. If the samecode
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
andtype
with the samecode
are considered different versions of the same product. More recent (newer)updateTime
s supersede less recent (older)updateTimes
.
-
-
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.
-
-
-
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 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:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(ProductId that)
Implement the Comparable interface.- Specified by:
compareTo
in 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:
hashCode
in 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.
-
-