Package net.solarnetwork.central.domain
Class UserUuidPK
java.lang.Object
net.solarnetwork.central.domain.BasePK
net.solarnetwork.central.domain.UserUuidPK
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<UserUuidPK>,CompositeKey,CompositeKey2<Long,,UUID> UserIdRelated
public final class UserUuidPK
extends BasePK
implements Serializable, Cloneable, Comparable<UserUuidPK>, CompositeKey2<Long,UUID>, UserIdRelated
Immutable primary key for user-related entities using a UUID primary key.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UserUuidPKclone()intcreateKey(CompositeKey template, Object... components) Create a new key instance based on a template and component arguments.booleanfinal LongGet the user ID.final UUIDgetUuid()Get the UUID.inthashCode()final LongGet the first key component.final UUIDGet the second key component.final booleankeyComponentIsAssigned(int index) Test if a given key component is assigned a value or not.<T> TkeyComponentValue(int index, Object val) Convert a value into a key component value.protected voidPopulate a string builder with an ID value.protected voidPopulate a string builder with a friendly string value.static UserUuidPKunassignedUuidKey(Long userId) Create a new instance using the "unassigned" UUID value.final booleanTest if the user ID is assigned.final booleanTest if the UUID is assigned.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.solarnetwork.central.domain.CompositeKey2
keyComponent, keyComponentLength
-
Field Details
-
UNASSIGNED_USER_ID
A special "not a value" instance to be used for generated user ID values yet to be generated. -
UNASSIGNED_UUID_ID
A special "not a value" instance to be used for generated UUID values yet to be generated.
-
-
Constructor Details
-
UserUuidPK
Constructor.- Parameters:
userId- the user IDuuid- the UUID- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
unassignedUuidKey
Create a new instance using the "unassigned" UUID value.- Parameters:
userId- the ID of the user to use- Returns:
- the new key instance
-
compareTo
- Specified by:
compareToin interfaceComparable<UserUuidPK>
-
populateIdValue
Description copied from class:BasePKPopulate a string builder with an ID value.This method is called from
BasePK.getId().- Specified by:
populateIdValuein classBasePK- Parameters:
buf- the buffer to populate
-
populateStringValue
Description copied from class:BasePKPopulate a string builder with a friendly string value.This method is called from
BasePK.toString(). The buffer will be initially empty when invoked.- Specified by:
populateStringValuein classBasePK- Parameters:
buf- the buffer to populate
-
clone
-
hashCode
public int hashCode() -
equals
-
getUserId
Get the user ID.- Specified by:
getUserIdin interfaceUserIdRelated- Returns:
- the user ID
-
getUuid
Get the UUID.- Returns:
- the UUID
-
keyComponent1
Description copied from interface:CompositeKey2Get the first key component.- Specified by:
keyComponent1in interfaceCompositeKey2<Long,UUID> - Returns:
- the first key component
-
keyComponent2
Description copied from interface:CompositeKey2Get the second key component.- Specified by:
keyComponent2in interfaceCompositeKey2<Long,UUID> - Returns:
- the second key component
-
keyComponentIsAssigned
public final boolean keyComponentIsAssigned(int index) Description copied from interface:CompositeKeyTest if a given key component is assigned a value or not.This method is designed to support cases when the key component is generated by an external system (such as a database) but the value is not allowed to be null. In this situation a placeholder value representing "not a value" can be used, and this method should return false if that value has been set on the instance.
- Specified by:
keyComponentIsAssignedin interfaceCompositeKey- Specified by:
keyComponentIsAssignedin interfaceCompositeKey2<Long,UUID> - Parameters:
index- the component index to test, starting from 0- Returns:
- true if the key component's value should be considered "assigned", false otherwise
-
userIdIsAssigned
public final boolean userIdIsAssigned()Test if the user ID is assigned.- Returns:
- true if the user ID value is assigned, false if it is considered "not a value"
-
uuidIsAssigned
public final boolean uuidIsAssigned()Test if the UUID is assigned.- Returns:
- true if the entity ID value is assigned, false if it is considered "not a value"
-
keyComponentValue
Description copied from interface:CompositeKeyConvert a value into a key component value.- Specified by:
keyComponentValuein interfaceCompositeKey- Type Parameters:
T- the expected key component type- Parameters:
index- the index of the key component to convert the value forval- the value to convert, or null to use an "unassigned" value- Returns:
- the key component value
-
createKey
Description copied from interface:CompositeKeyCreate a new key instance based on a template and component arguments.If less component values are provided than the length of the given key type, then "unassigned" values will be used for those components.
- Specified by:
createKeyin interfaceCompositeKey- Parameters:
template- the template key, or the implementation may support null to create a new key from scratch, or elseUnsupportedOperationExceptionwill be throwncomponents- the component values to use- Returns:
- the new key instance
-