Class LazyUid

  • All Implemented Interfaces:
    java.io.Serializable

    public class LazyUid
    extends java.lang.Object
    implements java.io.Serializable
    Lazily initialized, thread-safe, random UUID. Useful for identifying instances for logging & debugging purposes.

    The UUID value gets initialized with the first call to value() method. Once initialized, the UUID value stays the same.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID  
      private java.util.concurrent.atomic.AtomicReference<java.lang.String> uid  
    • Constructor Summary

      Constructors 
      Constructor Description
      LazyUid()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object that)  
      int hashCode()  
      java.lang.String toString()  
      java.lang.String value()
      Return UUID value.
      • Methods inherited from class java.lang.Object

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

      • uid

        private final java.util.concurrent.atomic.AtomicReference<java.lang.String> uid
    • Constructor Detail

      • LazyUid

        public LazyUid()
    • Method Detail

      • value

        public java.lang.String value()
        Return UUID value. The returned value is never null.
        Returns:
        UUID value.
      • equals

        public boolean equals​(java.lang.Object that)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object