Class UserUuidLongCompositePK

java.lang.Object
net.solarnetwork.central.domain.BasePK
net.solarnetwork.central.domain.UserUuidLongCompositePK
All Implemented Interfaces:
Serializable, Cloneable, Comparable<UserUuidLongCompositePK>, CompositeKey, CompositeKey3<Long,UUID,Long>, UserIdRelated

public class UserUuidLongCompositePK extends BasePK implements Serializable, Cloneable, Comparable<UserUuidLongCompositePK>, CompositeKey3<Long,UUID,Long>, UserIdRelated
Basic implementation of a Long, UUID, Long composite key.
See Also:
  • Field Details

    • UNASSIGNED_USER_ID

      public static final Long UNASSIGNED_USER_ID
      A special "not a value" instance to be used for generated user ID values yet to be generated.
    • UNASSIGNED_GROUP_ID

      public static final UUID UNASSIGNED_GROUP_ID
      A special "not a value" instance to be used for generated group ID values yet to be generated.
    • UNASSIGNED_ENTITY_ID

      public static final Long UNASSIGNED_ENTITY_ID
      A special "not a value" instance to be used for generated entity ID values yet to be generated.
  • Constructor Details

    • UserUuidLongCompositePK

      public UserUuidLongCompositePK(Long userId, UUID groupId, Long entityId)
      Constructor.
      Parameters:
      userId - the user ID
      groupId - the user ID
      entityId - the entity ID
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • unassignedEntityIdKey

      public static UserUuidLongCompositePK unassignedEntityIdKey(Long userId)
      Create a new instance using the "unassigned" entity ID value.
      Parameters:
      userId - the user ID to use
      groupId - the ID of the group to use
      Returns:
      the new key instance
    • unassignedEntityIdKey

      public static UserUuidLongCompositePK unassignedEntityIdKey(Long userId, UUID groupId)
      Create a new instance using the "unassigned" entity ID value.
      Parameters:
      userId - the user ID to use
      groupId - the ID of the group to use
      Returns:
      the new key instance
    • compareTo

      public int compareTo(UserUuidLongCompositePK o)
      Specified by:
      compareTo in interface Comparable<UserUuidLongCompositePK>
    • populateIdValue

      protected void populateIdValue(StringBuilder buf)
      Description copied from class: BasePK
      Populate a string builder with an ID value.

      This method is called from BasePK.getId().

      Specified by:
      populateIdValue in class BasePK
      Parameters:
      buf - the buffer to populate
    • populateStringValue

      protected void populateStringValue(StringBuilder buf)
      Description copied from class: BasePK
      Populate 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:
      populateStringValue in class BasePK
      Parameters:
      buf - the buffer to populate
    • clone

      protected UserLongCompositePK clone()
      Overrides:
      clone in class BasePK
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • ident

      public String ident()
      Get a short identifier string.

      The format of the returned string is (userId,groupId,entityId).

      Returns:
      the identifier
    • getUserId

      public final Long getUserId()
      Get the user ID.
      Specified by:
      getUserId in interface UserIdRelated
      Returns:
      the user ID
    • getGroupId

      public final UUID getGroupId()
      Get the group ID.
      Returns:
      the user ID
    • getEntityId

      public final Long getEntityId()
      Get the entity ID.
      Returns:
      the entity ID
    • keyComponent1

      public final Long keyComponent1()
      Description copied from interface: CompositeKey3
      Get the first key component.
      Specified by:
      keyComponent1 in interface CompositeKey3<Long,UUID,Long>
      Returns:
      the first key component
    • keyComponent2

      public final UUID keyComponent2()
      Description copied from interface: CompositeKey3
      Get the second key component.
      Specified by:
      keyComponent2 in interface CompositeKey3<Long,UUID,Long>
      Returns:
      the second key component
    • keyComponent3

      public final Long keyComponent3()
      Description copied from interface: CompositeKey3
      Get the third key component.
      Specified by:
      keyComponent3 in interface CompositeKey3<Long,UUID,Long>
      Returns:
      the third key component
    • keyComponentIsAssigned

      public final boolean keyComponentIsAssigned(int index)
      Description copied from interface: CompositeKey
      Test 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:
      keyComponentIsAssigned in interface CompositeKey
      Specified by:
      keyComponentIsAssigned in interface CompositeKey3<Long,UUID,Long>
      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

      public <T> T keyComponentValue(int index, Object val)
      Description copied from interface: CompositeKey
      Convert a value into a key component value.
      Specified by:
      keyComponentValue in interface CompositeKey
      Type Parameters:
      T - the expected key component type
      Parameters:
      index - the index of the key component to convert the value for
      val - the value to convert, or null to use an "unassigned" value
      Returns:
      the key component value
    • createKey

      public UserUuidLongCompositePK createKey(CompositeKey template, Object... components)
      Description copied from interface: CompositeKey
      Create 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:
      createKey in interface CompositeKey
      Parameters:
      template - the template key, or the implementation may support null to create a new key from scratch, or else UnsupportedOperationException will be thrown
      components - the component values to use
      Returns:
      the new key instance