Github user chtompki commented on a diff in the pull request:
https://github.com/apache/commons-text/pull/62#discussion_r140835603
--- Diff: src/main/java/org/apache/commons/text/RandomStringGenerator.java
---
@@ -324,6 +324,40 @@ public Builder withinRange(final int minimumCodePoint,
final int maximumCodePoin
/**
* <p>
+ * Specifies the array of minimum and maximum char allowed in the
+ * generated string.
+ * </p>
+ *
+ * For example:
+ * <pre>
+ * {@code
+ * char [][] pairs = {{'0','9'}};
+ * char [][] pairs = {{'a','z'}};
+ * char [][] pairs = {{'a','z'},{'0','9'}};
+ * }
+ * </pre>
+ *
+ * @param pairs array of charachters array, expected is to pass
min, max pairs through this arg.
+ * @return {@code this}, to allow method chaining.
+ */
+ public Builder withinRange(final char[] ... pairs) {
+ characterList = new ArrayList<Character>();
+ for (char[] pair : pairs) {
+ final int minimumCodePoint = pair[0];
+ final int maximumCodePoint = pair[1];
--- End diff --
Do we want validation on the definition of a `pair` here? Do we want to
throw an `InvalidParameterException` in this fashion:
```java
for(char[] pair: pairs) {
if (pair.length != 2) {
throw new InvalidParameterException("A char[] pair should look
like {'<char minimumCodePoint>', '<char maximumCodePoint>'}");
}
}
I'm not sure. I could go either way. Thoughts?
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]