Class TechKey

java.lang.Object
de.hybris.platform.sap.core.common.TechKey
All Implemented Interfaces:
Serializable

public final class TechKey extends Object implements Serializable
Class representing the concept of an unique identifier for an object. The key may be a database primary key, a GUID or some other identifier.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TechKey
    An empty TechKey.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance by providing a string representation of the key.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares this TechKey to the specified object.
    static TechKey
    fromUUIDString(String uuidString)
    Creates a new unique technical key using as GUID with length 32 using the UUID string format.
    static TechKey
    Creates a new unique technical key using as GUID with length 32 using the class UUID.
    Retrieves the id as a String.
    int
    Returns the hash code of the key.
    static boolean
    isEmpty(TechKey techKey)
    Checks if the passed TechKey instance is empty.
    boolean
    Tells you, whether the actual key is initial or not.
    Returns the string representation of the TechKey.
    Returns the UUID string representation of the given object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY_KEY

      public static final TechKey EMPTY_KEY
      An empty TechKey. Use this if you need an empty technical key for your purposes. Do not create them with new TechKey(""). If you ask this key if its initial it says "yes I am".
  • Constructor Details

    • TechKey

      public TechKey(String id)
      Creates a new instance by providing a string representation of the key. Do not create new technical keys using new TechKey(null) but use the defined static final EMPTY_KEY.
      Parameters:
      id - key to be used for the construction
  • Method Details

    • isInitial

      public boolean isInitial()
      Tells you, whether the actual key is initial or not.
      Returns:
      true if the key is initial or false if its not.
    • getIdAsString

      public String getIdAsString()
      Retrieves the id as a String.
      Returns:
      String representation of the key
    • isEmpty

      public static boolean isEmpty(TechKey techKey)
      Checks if the passed TechKey instance is empty.

      It is empty, if the id is null or if the content as String contains whitespaces only.

      Parameters:
      techKey - TechKey instance
      Returns:
      true if the provided techKey is empty
    • toString

      public String toString()
      Returns the string representation of the TechKey.
      Overrides:
      toString in class Object
      Returns:
      String string representation
    • toUUIDString

      public String toUUIDString()
      Returns the UUID string representation of the given object.

      Example: 12345678-9012-3456-7890-1234567890AB

      Returns:
      UUID String representation
    • hashCode

      public int hashCode()
      Returns the hash code of the key.
      Overrides:
      hashCode in class Object
      Returns:
      hash code
    • equals

      public boolean equals(Object o)
      Compares this TechKey to the specified object. The result is true if and only if the argument is not null and is a TechKey object that represents the same key value as this object.
      Overrides:
      equals in class Object
      Parameters:
      o - object to compare with
      Returns:
      true if the keys are identical; otherwise false.
    • generateKey

      public static TechKey generateKey()
      Creates a new unique technical key using as GUID with length 32 using the class UUID.
      Returns:
      new unique technical key
    • fromUUIDString

      public static TechKey fromUUIDString(String uuidString)
      Creates a new unique technical key using as GUID with length 32 using the UUID string format.
      Parameters:
      uuidString - UUID formatted String
      Returns:
      new unique technical key