NoIssue: Better fail safety
This commit is contained in:
@@ -4,12 +4,19 @@ import com.r35157.libs.random.RandomValueGeneratorInt;
|
||||
import com.r35157.libs.random.RandomValueGeneratorString;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class RandomValueGeneratorStringImpl implements RandomValueGeneratorString {
|
||||
public RandomValueGeneratorStringImpl(@NotNull RandomValueGeneratorInt rvgi) {
|
||||
Objects.requireNonNull(rvgi, "Cannot initialize with <null> RandomValueGeneratorInt!");
|
||||
this.rvgi = rvgi;
|
||||
}
|
||||
|
||||
public @NotNull String getSomeStringAlphaNumericOnly(int length) {
|
||||
public @NotNull String getSomeStringAlphaNumericOnly(int length) throws IllegalArgumentException {
|
||||
if(length < 0) {
|
||||
throw new IllegalArgumentException("Cannot generate random Strings of size " + length + "!");
|
||||
}
|
||||
|
||||
// ASCII Range size
|
||||
// Numeric 48-57 10
|
||||
// Alpha upper 65-90 26
|
||||
|
||||
Reference in New Issue
Block a user