Package gov.usgs.earthquake.product
Class ProductId
java.lang.Object
gov.usgs.earthquake.product.ProductId
- All Implemented Interfaces:
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintImplement the Comparable interface.booleanOverride the default Object.equals().static ProductIdfromJson(javax.json.JsonObject jsonObject) Create a new ProductId from JsonObjectgetCode()getType()inthashCode()Override default Object.hashCode().booleanisSameProduct(ProductId that) Whether these are the same product, even if they are different versions.static ProductIdParse a product id string.voidvoidvoidvoidsetUpdateTime(Date updateTime) toString()Convert this product id to a string.
-
Constructor Details
-
ProductId
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
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
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
- Returns:
- the source
-
setSource
- Parameters:
source- the source to set
-
getType
- Returns:
- the type
-
setType
- Parameters:
type- the type to set
-
getCode
- Returns:
- the code
-
setCode
- Parameters:
code- the code to set
-
getUpdateTime
- Returns:
- the updateTime
-
setUpdateTime
- Parameters:
updateTime- the updateTime to set
-
toString
Convert this product id to a string. This string does not include the update time. -
parse
Parse a product id string.- Parameters:
str- a valid product id string.- Returns:
- a ProductId object.
-
equals
Override the default Object.equals(). -
compareTo
Implement the Comparable interface.- Specified by:
compareToin interfaceComparable<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(). -
isSameProduct
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.
-