Class RandomString

java.lang.Object
dev.demeng.pluginbase.random.RandomString

public final class RandomString extends Object
Utility for generating random strings with customizable length.

WARNING: IDs generated with this utility are NOT guaranteed to be random, though the chance of getting a duplicate ID becomes increasingly unlikely as you increase the length.

  • Field Details

    • ALPHABET_UPPER

      public static final char[] ALPHABET_UPPER
    • ALPHABET_LOWER

      public static final char[] ALPHABET_LOWER
    • NUMBERS

      public static final char[] NUMBERS
    • ALPHANUMERIC_UPPER

      public static final char[] ALPHANUMERIC_UPPER
    • ALPHANUMERIC_LOWER

      public static final char[] ALPHANUMERIC_LOWER
    • ALPHANUMERIC_MIXED

      public static final char[] ALPHANUMERIC_MIXED
  • Constructor Details

    • RandomString

      public RandomString()
  • Method Details

    • generate

      @NotNull public static @NotNull String generate(int length, char[] chars)
      Generates a new "unique" string identifier with the specified length.
      Parameters:
      length - The length of the ID
      Returns:
      The generated ID