com.amazon.redshift.plugin.utils.RandomStateUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redshift-jdbc42 Show documentation
Show all versions of redshift-jdbc42 Show documentation
Java JDBC 4.2 (JRE 8+) driver for Redshift database
The newest version!
package com.amazon.redshift.plugin.utils;
import java.util.Random;
/**
* Random state string generating util.
*/
public class RandomStateUtil
{
/**
* Length of the random state string.
*/
private static final int DEFAULT_STATE_STRING_LENGTH = 10;
/**
* Generates random state string 10 char length.
*
* @return generated randomly.
*/
public static String generateRandomState()
{
return generateRandomString();
}
/**
* @return string generated randomly.
*/
private static String generateRandomString()
{
Random random = new Random(System.currentTimeMillis());
StringBuilder buffer = new StringBuilder(DEFAULT_STATE_STRING_LENGTH);
for (int i = 0; i < DEFAULT_STATE_STRING_LENGTH; i++)
{
buffer.append((char) (random.nextInt(26) + 'a'));
}
return buffer.toString();
}
}