Class StringIncubator

  • All Implemented Interfaces:
    Serializable

    public class StringIncubator
    extends Object
    implements Serializable
    You can use this class if you need to Generate Random String/Alpha-numeric string for Tickets, Session, ID etc. To generate random string you can use the default the constructor that suit your purpose or the default option which will generate string of 64 characters.

    Example/Usage:

    StringIncubator gen = new StringIncubator(12); StringIncubator session = new StringIncubator();

    StringIncubator gen = new StringIncubator(12, ThreadLocalRandom.current());

    String symbol = StringIncubator.DIGITS + "ACEFGHJKLMNPQRUVWXYabcdefhijkprstuvwx"; StringIncubator tickets = new StringIncubator(23, new SecureRandom(), symbol);
    Since:
    1.0
    Author:
    , Bobai Kato, Erickson (https://stackoverflow.com/users/3474/erickson)
    See Also:
    Serialized Form
    • Constructor Detail

      • StringIncubator

        public StringIncubator​(int length,
                               ThreadLocalRandom random)
        Constructor to hatch an alphanumeric string generator.
        Parameters:
        length - of hatched string/value
        random - any instance of ThreadLocalRandom as required
        Since:
        1.0
      • StringIncubator

        public StringIncubator​(int length,
                               Random random,
                               String symbols)
        Constructor which take the require hatch length, instance of Random and String from which to hatch the random values.
        Parameters:
        length - of hatched string/value
        random - any instance of Random as required
        symbols - String to generate the hatched values
        Since:
        1.0
      • StringIncubator

        public StringIncubator​(int length,
                               String symbols)
        Create an alphanumeric string from a secure generator.
        Parameters:
        symbols - String to generate the hatched values
        length - of hatched string/value
        Since:
        1.0
      • StringIncubator

        public StringIncubator()
        Create session identifiers, default length of 64.
        Since:
        1.0
      • StringIncubator

        public StringIncubator​(int length)
        Create an alphanumeric string from a secure generator.
        Parameters:
        length - of hatched string/value
        Since:
        1.0
      • StringIncubator

        public StringIncubator​(int length,
                               Random random)
        Constructor to hatch an alphanumeric string generator.
        Parameters:
        length - of hatched string/value
        random - any instance of Random as required
        Since:
        1.0
    • Method Detail

      • getUpper

        @Contract(pure=true)
        public static String getUpper()
        Upper-case Alphabets.
        Since:
        1.0
      • setUpper

        public static void setUpper​(@NotNull
                                    @NotNull String uppercaseValue)
        Use this set the Upper case characters.
        Parameters:
        uppercaseValue - the upper case values.
      • getLower

        @Contract(pure=true)
        public static String getLower()
        Lower-case Alphabets.
        Since:
        1.0
      • setLower

        public static void setLower​(@NotNull
                                    @NotNull String lowercaseValue)
        Use this method to set Lower-case characters.
        Parameters:
        lowercaseValue - the lower case values.
      • hatch

        public String hatch()
        Generate and returns random string.
        Since:
        1.0