Class KeyTypePK

java.lang.Object
net.solarnetwork.central.domain.BasePK
net.solarnetwork.central.domain.KeyTypePK
All Implemented Interfaces:
Serializable, Cloneable, Comparable<KeyTypePK>

public class KeyTypePK extends BasePK implements Cloneable, Serializable, Comparable<KeyTypePK>
Primary key based on a key/type string tuple.
Since:
2.0
See Also:
  • Constructor Details

  • Method Details

    • keyType

      public static KeyTypePK keyType(String key, String type)
      Create a new key instance.
      Parameters:
      key - the key
      type - the type
      Returns:
      the key
      Throws:
      IllegalArgumentException - if any argument is null
    • 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
    • hashCode

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

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

      public int compareTo(KeyTypePK o)
      Compare two KeyTypePK objects.

      Keys are ordered based on:

      1. key
      2. type
      Specified by:
      compareTo in interface Comparable<KeyTypePK>
      Parameters:
      o - the object to compare to
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • getKey

      public String getKey()
      Get the key.
      Returns:
      the key
    • getType

      public String getType()
      Get the type.
      Returns:
      the type