Package net.solarnetwork.central.domain
Class UserLongIntegerCompositePK
java.lang.Object
net.solarnetwork.central.domain.BasePK
net.solarnetwork.central.domain.UserLongIntegerCompositePK
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<UserLongIntegerCompositePK>,CompositeKey,CompositeKey3<Long,,Long, Integer> UserIdRelated
public final class UserLongIntegerCompositePK
extends BasePK
implements Serializable, Cloneable, Comparable<UserLongIntegerCompositePK>, CompositeKey3<Long,Long,Integer>, UserIdRelated
Basic implementation of a Long, Long, Integer composite key.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IntegerA special "not a value" instance to be used for generated entity ID values yet to be generated.static final LongA special "not a value" instance to be used for generated group ID values yet to be generated.static final LongA special "not a value" instance to be used for generated user ID values yet to be generated. -
Constructor Summary
ConstructorsConstructorDescriptionUserLongIntegerCompositePK(Long userId, Long groupId, Integer entityId) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected UserLongCompositePKclone()intcreateKey(CompositeKey template, Object... components) Create a new key instance based on a template and component arguments.final booleanTest if the entity ID is assigned.booleanfinal IntegerGet the entity ID.final LongGet the group ID.final LongGet the user ID.final booleanTest if the group ID is assigned.inthashCode()ident()Get a short identifier string.final LongGet the first key component.final LongGet the second key component.final IntegerGet the third 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 UserLongIntegerCompositePKunassignedEntityIdKey(Long userId, Long groupId) Create a new instance using the "unassigned" entity ID value.final booleanTest if the user ID is assigned.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.solarnetwork.central.domain.CompositeKey3
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_GROUP_ID
A special "not a value" instance to be used for generated group ID values yet to be generated. -
UNASSIGNED_ENTITY_ID
A special "not a value" instance to be used for generated entity ID values yet to be generated.
-
-
Constructor Details
-
UserLongIntegerCompositePK
Constructor.- Parameters:
userId- the user IDgroupId- the user IDentityId- the entity ID- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
unassignedEntityIdKey
Create a new instance using the "unassigned" entity ID value.- Parameters:
userId- the user ID to usegroupId- the ID of the group to use- Returns:
- the new key instance
-
compareTo
- Specified by:
compareToin interfaceComparable<UserLongIntegerCompositePK>
-
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
-
ident
Get a short identifier string.The format of the returned string is
(userId,groupId,entityId).- Returns:
- the identifier
-
getUserId
Get the user ID.- Specified by:
getUserIdin interfaceUserIdRelated- Returns:
- the user ID
-
getGroupId
Get the group ID.- Returns:
- the user ID
-
getEntityId
Get the entity ID.- Returns:
- the entity ID
-
keyComponent1
Description copied from interface:CompositeKey3Get the first key component.- Specified by:
keyComponent1in interfaceCompositeKey3<Long,Long, Integer> - Returns:
- the first key component
-
keyComponent2
Description copied from interface:CompositeKey3Get the second key component.- Specified by:
keyComponent2in interfaceCompositeKey3<Long,Long, Integer> - Returns:
- the second key component
-
keyComponent3
Description copied from interface:CompositeKey3Get the third key component.- Specified by:
keyComponent3in interfaceCompositeKey3<Long,Long, Integer> - Returns:
- the third 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 interfaceCompositeKey3<Long,Long, Integer> - 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"
-
groupIdIsAssigned
public final boolean groupIdIsAssigned()Test if the group ID is assigned.- Returns:
- true if the group ID value is assigned, false if it is considered "not a value"
-
entityIdIsAssigned
public final boolean entityIdIsAssigned()Test if the entity ID 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
-