Class RandomString

java.lang.Object
net.bytebuddy.utility.RandomString

public class RandomString extends Object
A provider of randomized String values.
  • Field Details

    • DEFAULT_LENGTH

      public static final int DEFAULT_LENGTH
      The default length of a randomized String.
      See Also:
    • SYMBOL

      private static final char[] SYMBOL
      The symbols which are used to create a random String.
    • KEY_BITS

      private static final int KEY_BITS
      The amount of bits to extract out of an integer for each key generated.
    • random

      private final Random random
      A provider of random values.
    • length

      private final int length
      The length of the random strings that are created by this instance.
  • Constructor Details

    • RandomString

      public RandomString()
      Creates a random String provider where each String is of DEFAULT_LENGTH length.
    • RandomString

      public RandomString(int length)
      Creates a random String provider where each value is of the given length.
      Parameters:
      length - The length of the random String.
    • RandomString

      public RandomString(int length, Random random)
      Creates a random String provider where each value is of the given length.
      Parameters:
      length - The length of the random String.
      random - The random number generator to use.
  • Method Details

    • make

      public static String make()
      Creates a random String of DEFAULT_LENGTH length.
      Returns:
      A random String.
    • make

      public static String make(int length)
      Creates a random String of the given length.
      Parameters:
      length - The length of the random String.
      Returns:
      A random String.
    • hashOf

      public static String hashOf(@MaybeNull Object value)
      Represents a object value as a string hash. This string is not technically random but generates a fixed character sequence based on the hash provided.
      Parameters:
      value - The value to represent as a string or null.
      Returns:
      A string representing the supplied value as a string.
    • hashOf

      public static String hashOf(int value)
      Represents an integer value as a string hash. This string is not technically random but generates a fixed character sequence based on the hash provided.
      Parameters:
      value - The value to represent as a string.
      Returns:
      A string representing the supplied value as a string.
    • nextString

      public String nextString()
      Creates a new random String.
      Returns:
      A random String of the given length for this instance.