Class RestateRandom

  • All Implemented Interfaces:
    java.io.Serializable

    public class RestateRandom
    extends java.util.Random
    Subclass of Random inherently predictable, seeded on the InvocationId, which is not secret.

    This instance is useful to generate identifiers, idempotency keys, and for uniform sampling from a set of options. If a cryptographically secure value is needed, please generate that externally using Context.run(Serde, ThrowingSupplier).

    You MUST NOT use this object inside a Context.run(Serde, ThrowingSupplier).

    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int next​(int bits)  
      java.util.UUID nextUUID()  
      void setSeed​(long seed)  
      • Methods inherited from class java.util.Random

        doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong
      • Methods inherited from class java.lang.Object

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

      • setSeed

        public void setSeed​(long seed)
        Overrides:
        setSeed in class java.util.Random
        Throws:
        java.lang.UnsupportedOperationException - You cannot set the seed on RestateRandom
      • nextUUID

        public java.util.UUID nextUUID()
        Returns:
        a UUID generated using this RNG that is stable across retries and replays.
      • next

        protected int next​(int bits)
        Overrides:
        next in class java.util.Random