Class ToUUID

  • All Implemented Interfaces:
    java.util.function.LongFunction<java.util.UUID>

    public class ToUUID
    extends java.lang.Object
    implements java.util.function.LongFunction<java.util.UUID>
    This function creates a non-random UUID in the type 4 version (Random). It always puts the same value in the MSB position of the UUID format. The input value is put in the LSB position.
     xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
     mmmmmmmm-mmmm-Mmmm-Llll-llllllllllll
                   4    3
     
    As shown above, the LSB position does not have the complication of having a version identifier (position M) dividing the dynamic range of the data type. For this reason, only the LSB side is used for this mapper, which allows an effective range of Long.MAX_VALUE/8, given the loss of 3 digits of precision. This function is suitable for deterministic testing of scenarios which depend on type 4 UUIDs, but without the mandated randomness that makes testing difficult. Just be aware that the MSB will always contain value 0x0123456789ABCDEFL unless you specify a different long value to pre-fill it with.
    • Constructor Summary

      Constructors 
      Constructor Description
      ToUUID()  
      ToUUID​(long msbs)  
    • Method Summary

      Modifier and Type Method Description
      java.util.UUID apply​(long value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ToUUID

        public ToUUID()
      • ToUUID

        public ToUUID​(long msbs)
    • Method Detail

      • apply

        public java.util.UUID apply​(long value)
        Specified by:
        apply in interface java.util.function.LongFunction<java.util.UUID>