Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,88 @@ class ProductId {
/**
* Identifying number used in conjunction with the type
*/
private final String identifier
private final long uniqueId

/**
* A builder for ProductId instances.
*/
static class Builder {
private String productType
private long uniqueId

/**
*
* @param productType
* @param identifier the unique id - will be interpreted as unsigned long
*/
Builder(String productType, String identifier) {
this.productType = Objects.requireNonNull(productType)
this.uniqueId = Objects.requireNonNull(Long.parseUnsignedLong(identifier))
}

/**
*
* @param productType
* @param uniqueId the unique id - will be interpreted as unsigned long
*/
Builder(String productType, long uniqueId) {
this.productType = Objects.requireNonNull(productType)
this.uniqueId = Objects.requireNonNull(uniqueId)
}

Builder productType(String productType) {
this.productType = productType
return this
}

Builder uniqueId(long identifier) {
this.uniqueId = identifier
return this
}
/**
* Constructs a product identifier based on the configuration of the builder
* @return
*/
ProductId build() {
return new ProductId(this)
}
}

/**
* Creates an identifier object with the
*
* @param type describing the type of the underlying identifier
* @param identifier describes the identifying running number
* @deprecated please use {@link ProductId.Builder}
*/

@Deprecated
ProductId(String type, String identifier){
this.type = Objects.requireNonNull(type, "type must not be null")
this.identifier= Objects.requireNonNull(identifier, "version must not be null")
Builder builder = new Builder(type, identifier)
this.type = builder.productType
this.uniqueId = builder.uniqueId
}

private ProductId(Builder builder) {
this.type = builder.productType
this.uniqueId = builder.uniqueId
}

/**
* Returns the identifying running number
* @return
* @return the identifier
* @deprecated please use {@link ProductId#getUniqueId()}
*/
@Deprecated
String getIdentifier() {
return identifier
return uniqueId.toString()
}

/**
* Returns the identifying running number
* @return the identifier
*/
Long getUniqueId() {
return uniqueId
}
/**
* Returns the type of the identifier
Expand All @@ -62,6 +123,6 @@ class ProductId {
*/
@Override
String toString() {
return type + "_" + identifier
return "${type}_${uniqueId}"
}
}