Class TechKey
- java.lang.Object
-
- de.hybris.platform.sap.core.common.TechKey
-
- All Implemented Interfaces:
java.io.Serializable
public final class TechKey extends java.lang.Object implements java.io.SerializableClass 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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TechKey(java.lang.String id)Creates a new instance by providing a string representation of the key.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Compares this TechKey to the specified object.static TechKeyfromUUIDString(java.lang.String uuidString)Creates a new unique technical key using as GUID with length 32 using the UUID string format.static TechKeygenerateKey()Creates a new unique technical key using as GUID with length 32 using the class UUID.java.lang.StringgetIdAsString()Retrieves the id as aString.inthashCode()Returns the hash code of the key.static booleanisEmpty(TechKey techKey)Checks if the passed TechKey instance is empty.booleanisInitial()Tells you, whether the actual key is initial or not.java.lang.StringtoString()Returns the string representation of the TechKey.java.lang.StringtoUUIDString()Returns the UUID string representation of the given object.
-
-
-
Field Detail
-
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".
-
-
Method Detail
-
isInitial
public boolean isInitial()
Tells you, whether the actual key is initial or not.- Returns:
trueif the key is initial orfalseif its not.
-
getIdAsString
public java.lang.String getIdAsString()
Retrieves the id as aString.- 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
nullor if the content asStringcontains whitespaces only.- Parameters:
techKey- TechKey instance- Returns:
trueif the providedtechKeyis empty
-
toString
public java.lang.String toString()
Returns the string representation of the TechKey.- Overrides:
toStringin classjava.lang.Object- Returns:
- String string representation
-
toUUIDString
public java.lang.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:
hashCodein classjava.lang.Object- Returns:
- hash code
-
equals
public boolean equals(java.lang.Object o)
Compares this TechKey to the specified object. The result istrueif and only if the argument is notnulland is aTechKeyobject that represents the same key value as this object.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- object to compare with- Returns:
trueif the keys are identical; otherwisefalse.
-
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(java.lang.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
-
-