You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/06/29 02:11:41 UTC
[1/8] [text] TEXT-93: RandomStringGenerator accepts a list of valid
characters
Repository: commons-text
Updated Branches:
refs/heads/master 569dbc094 -> 5e479dcd7
TEXT-93: RandomStringGenerator accepts a list of valid characters
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/278f1e0f
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/278f1e0f
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/278f1e0f
Branch: refs/heads/master
Commit: 278f1e0fb553fc2d2d6f5563d9e61899776cd80d
Parents: e85959f
Author: Amey Jadiye <am...@gmail.com>
Authored: Fri Jun 23 02:48:11 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Fri Jun 23 02:48:11 2017 +0530
----------------------------------------------------------------------
.../commons/text/RandomStringGenerator.java | 102 +++++++++++++++++--
.../commons/text/RandomStringGeneratorTest.java | 31 ++++++
2 files changed, 122 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/278f1e0f/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index 6aa6806..d3d8567 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -16,12 +16,14 @@
*/
package org.apache.commons.text;
+import org.apache.commons.lang3.Validate;
+
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
-import org.apache.commons.lang3.Validate;
-
/**
* <p>
* Generates random Unicode strings containing the specified number of code points.
@@ -73,23 +75,29 @@ public final class RandomStringGenerator {
private final TextRandomProvider random;
/**
+ * The source of provided charachters.
+ */
+ private final List<Character> characterList;
+
+ /**
* Constructs the generator.
- *
- * @param minimumCodePoint
+ * @param minimumCodePoint
* smallest allowed code point (inclusive)
* @param maximumCodePoint
* largest allowed code point (inclusive)
* @param inclusivePredicates
- * filters for code points
- * @param random
- * source of randomness
+ * filters for code points
+ * @param random random generator
+ * @param characterList list of predefined set of characters
*/
private RandomStringGenerator(int minimumCodePoint, int maximumCodePoint,
- Set<CharacterPredicate> inclusivePredicates, TextRandomProvider random) {
+ Set<CharacterPredicate> inclusivePredicates, TextRandomProvider random,
+ List<Character> characterList) {
this.minimumCodePoint = minimumCodePoint;
this.maximumCodePoint = maximumCodePoint;
this.inclusivePredicates = inclusivePredicates;
this.random = random;
+ this.characterList = characterList;
}
/**
@@ -109,6 +117,23 @@ public final class RandomStringGenerator {
return ThreadLocalRandom.current().nextInt(minInclusive, maxInclusive + 1);
}
+
+
+ /**
+ * Generates a random number within a range, using a {@link ThreadLocalRandom} instance
+ * or the user-supplied source of randomness.
+ *
+ * @param characterList predefined char list.
+ * @return the random number.
+ */
+ private int generateRandomNumber(final List<Character> characterList) {
+ int listSize = characterList.size();
+ if (random != null) {
+ return String.valueOf(characterList.get(random.nextInt(listSize))).codePointAt(0);
+ }
+ return String.valueOf(characterList.get(ThreadLocalRandom.current().nextInt(0, listSize))).codePointAt(0);
+ }
+
/**
* <p>
* Generates a random string, containing the specified number of code points.
@@ -142,8 +167,12 @@ public final class RandomStringGenerator {
long remaining = length;
do {
- int codePoint = generateRandomNumber(minimumCodePoint, maximumCodePoint);
-
+ int codePoint;
+ if (characterList != null && characterList.size() > 0) {
+ codePoint = generateRandomNumber(characterList);
+ } else {
+ codePoint = generateRandomNumber(minimumCodePoint, maximumCodePoint);
+ }
switch (Character.getType(codePoint)) {
case Character.UNASSIGNED:
case Character.PRIVATE_USE:
@@ -234,6 +263,11 @@ public final class RandomStringGenerator {
private TextRandomProvider random;
/**
+ * The source of provided charachters.
+ */
+ private List<Character> characterList;
+
+ /**
* <p>
* Specifies the minimum and maximum code points allowed in the
* generated string.
@@ -336,12 +370,58 @@ public final class RandomStringGenerator {
}
/**
+ * <p>
+ * Limits the characters in the generated string to those who match at
+ * supplied list of Character.
+ * </p>
+ *
+ * <p>
+ * Passing {@code null} or an empty array to this method will revert to the
+ * default behaviour of allowing any character. Multiple calls to this
+ * method will replace the previously stored Character.
+ * </p>
+ *
+ * @param chars set of preefined Characters for random string generation
+ * the Character can be, may be {@code null} or empty
+ * @return {@code this}, to allow method chaining
+ */
+ public Builder selectFromList(char[] chars) {
+ characterList = new ArrayList<Character>();
+ for (char c : chars) {
+ characterList.add(c);
+ }
+ return this;
+ }
+
+ /**
+ * <p>
+ * Limits the characters in the generated string to those who match at
+ * supplied list of Character.
+ * </p>
+ *
+ * <p>
+ * Passing {@code null} or an empty array to this method will revert to the
+ * default behaviour of allowing any character. Multiple calls to this
+ * method will replace the previously stored Character.
+ * </p>
+ *
+ * @param characterList set of preefined Characters for random string generation
+ * the Character can be, may be {@code null} or empty
+ * @return {@code this}, to allow method chaining
+ */
+ public Builder selectFromList(List<Character> characterList) {
+ this.characterList = characterList;
+ return this;
+ }
+
+ /**
* <p>Builds the {@code RandomStringGenerator} using the properties specified.</p>
* @return the configured {@code RandomStringGenerator}
*/
@Override
public RandomStringGenerator build() {
- return new RandomStringGenerator(minimumCodePoint, maximumCodePoint, inclusivePredicates, random);
+ return new RandomStringGenerator(minimumCodePoint, maximumCodePoint, inclusivePredicates,
+ random, characterList);
}
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/278f1e0f/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
index 86537fa..463e767 100644
--- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
+++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
@@ -18,6 +18,9 @@ package org.apache.commons.text;
import org.junit.Test;
+import java.util.ArrayList;
+import java.util.List;
+
import static org.junit.Assert.*;
/**
@@ -203,4 +206,32 @@ public class RandomStringGeneratorTest {
RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
assertEquals("", generator.generate(0));
}
+
+ @Test
+ public void testSelectFromList() {
+ List<Character> list = new ArrayList<Character>();
+ list.add('a');
+ list.add('b');
+ list.add('c');
+ RandomStringGenerator generator = new RandomStringGenerator.Builder().selectFromList(list).build();
+
+ String randomText = generator.generate(5);
+
+ for (char c : randomText.toCharArray()) {
+ assertTrue(list.contains(c));
+ }
+ }
+
+ @Test
+ public void testSelectFromCharArray() {
+ String str = "abc";
+ char[] charArray = str.toCharArray();
+ RandomStringGenerator generator = new RandomStringGenerator.Builder().selectFromList(charArray).build();
+
+ String randomText = generator.generate(5);
+
+ for (char c : randomText.toCharArray()) {
+ assertTrue(str.indexOf(c) != -1);
+ }
+ }
}
[4/8] [text] Merge branch 'TEXT-93' of
github.com:ameyjadiye/commons-text into TEXT-93
Posted by ch...@apache.org.
Merge branch 'TEXT-93' of github.com:ameyjadiye/commons-text into TEXT-93
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/b7ac42b2
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/b7ac42b2
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/b7ac42b2
Branch: refs/heads/master
Commit: b7ac42b27d0c0678a18c39b2929a21725aed6086
Parents: c1aabc0 2dfadf4
Author: Amey Jadiye <am...@gmail.com>
Authored: Fri Jun 23 11:10:51 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Fri Jun 23 11:10:51 2017 +0530
----------------------------------------------------------------------
.travis.yml | 2 +-
README.md | 2 +-
RELEASE-NOTES.txt | 42 ++-
checkstyle.xml | 4 +-
pom.xml | 17 +-
src/changes/changes.xml | 12 +-
.../java/org/apache/commons/text/CaseUtils.java | 135 ++++++++++
.../commons/text/CharacterPredicates.java | 61 +++++
.../commons/text/RandomStringGenerator.java | 26 +-
.../commons/text/translate/CsvTranslators.java | 12 +-
.../text/translate/NumericEntityEscaper.java | 23 +-
.../release-notes/RELEASE-NOTES-1.0.txt | 2 +-
.../release-notes/RELEASE-NOTES-1.1.txt | 181 +++++++++++++
src/site/xdoc/download_text.xml | 26 +-
src/site/xdoc/index.xml | 8 +-
src/site/xdoc/release-history.xml | 5 +-
.../org/apache/commons/text/CaseUtilsTest.java | 80 ++++++
.../commons/text/CharacterPredicatesTest.java | 66 +++++
.../commons/text/RandomStringGeneratorTest.java | 25 ++
.../org/apache/commons/text/StrBuilderTest.java | 257 +++++++++++++------
.../apache/commons/text/StrTokenizerTest.java | 29 ++-
.../org/apache/commons/text/WordUtilsTest.java | 3 +
.../text/translate/CsvTranslatorsTest.java | 205 +++++++--------
23 files changed, 983 insertions(+), 240 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/b7ac42b2/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
[6/8] [text] added selectFrom method with varargs
Posted by ch...@apache.org.
added selectFrom method with varargs
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/df30bf96
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/df30bf96
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/df30bf96
Branch: refs/heads/master
Commit: df30bf96856287478f3a7dfa7f017ca175bdd352
Parents: f9177e2
Author: Amey Jadiye <am...@gmail.com>
Authored: Sat Jun 24 00:57:17 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Sat Jun 24 00:57:17 2017 +0530
----------------------------------------------------------------------
.../commons/text/RandomStringGenerator.java | 26 +-----------------
.../commons/text/RandomStringGeneratorTest.java | 29 ++++++--------------
2 files changed, 9 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/df30bf96/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index 0111746..dc338f0 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -409,7 +409,7 @@ public final class RandomStringGenerator {
* the Character can be, may be {@code null} or empty
* @return {@code this}, to allow method chaining
*/
- public Builder selectFromList(char[] chars) {
+ public Builder selectFrom(char ... chars) {
characterList = new ArrayList<Character>();
for (char c : chars) {
characterList.add(c);
@@ -418,30 +418,6 @@ public final class RandomStringGenerator {
}
/**
- * <p>
- * Limits the characters in the generated string to those who match at
- * supplied list of Character.
- * </p>
- *
- * <p>
- * Passing {@code null} or an empty array to this method will revert to the
- * default behaviour of allowing any character. Multiple calls to this
- * method will replace the previously stored Character.
- * </p>
- *
- * @param characterList set of preefined Characters for random string generation
- * the Character can be, may be {@code null} or empty
- * @return {@code this}, to allow method chaining
- */
- public Builder selectFromList(List<Character> characterList) {
- this.characterList = new ArrayList<Character>();
- for (char c : characterList) {
- this.characterList.add(c);
- }
- return this;
- }
-
- /**
* <p>Builds the {@code RandomStringGenerator} using the properties specified.</p>
* @return the configured {@code RandomStringGenerator}
*/
http://git-wip-us.apache.org/repos/asf/commons-text/blob/df30bf96/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
index 3769be2..bf00b5c 100644
--- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
+++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
@@ -232,37 +232,24 @@ public class RandomStringGeneratorTest {
assertEquals("", generator.generate(0));
}
-
-
-
-
-
-
-
-
@Test
- public void testSelectFromList() {
- List<Character> list = new ArrayList<Character>();
- list.add('a');
- list.add('b');
- list.add('c');
- RandomStringGenerator generator = new RandomStringGenerator.Builder().selectFromList(list).build();
+ public void testSelectFromCharArray() {
+ String str = "abc";
+ char[] charArray = str.toCharArray();
+ RandomStringGenerator generator = new RandomStringGenerator.Builder().selectFrom(charArray).build();
String randomText = generator.generate(5);
for (char c : randomText.toCharArray()) {
- assertTrue(list.contains(c));
+ assertTrue(str.indexOf(c) != -1);
}
}
@Test
- public void testSelectFromCharArray() {
- String str = "abc";
- char[] charArray = str.toCharArray();
- RandomStringGenerator generator = new RandomStringGenerator.Builder().selectFromList(charArray).build();
-
+ public void testSelectFromCharVarargs() {
+ String str="abc";
+ RandomStringGenerator generator = new RandomStringGenerator.Builder().selectFrom('a','b','c').build();
String randomText = generator.generate(5);
-
for (char c : randomText.toCharArray()) {
assertTrue(str.indexOf(c) != -1);
}
[7/8] [text] fixed code formatting
Posted by ch...@apache.org.
fixed code formatting
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/9db77088
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/9db77088
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/9db77088
Branch: refs/heads/master
Commit: 9db77088ecc557c2f209dd36972746d6de8dfc4a
Parents: df30bf9
Author: Amey Jadiye <am...@gmail.com>
Authored: Sat Jun 24 19:35:12 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Sat Jun 24 19:35:12 2017 +0530
----------------------------------------------------------------------
.../org/apache/commons/text/RandomStringGenerator.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/9db77088/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index dc338f0..0dcf2a1 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -84,14 +84,16 @@ public final class RandomStringGenerator {
/**
* Constructs the generator.
- * @param minimumCodePoint
+ *
+ * @param minimumCodePoint
* smallest allowed code point (inclusive)
* @param maximumCodePoint
* largest allowed code point (inclusive)
* @param inclusivePredicates
- * filters for code points
- * @param random random generator
- * @param characterList list of predefined set of characters
+ * filters for code points
+ * @param random
+ * source of randomness
+ * @param characterList list of predefined set of characters.
*/
private RandomStringGenerator(int minimumCodePoint, int maximumCodePoint,
Set<CharacterPredicate> inclusivePredicates, TextRandomProvider random,
[2/8] [text] Merge branch 'master' into TEXT-93
Posted by ch...@apache.org.
Merge branch 'master' into TEXT-93
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/2dfadf4f
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/2dfadf4f
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/2dfadf4f
Branch: refs/heads/master
Commit: 2dfadf4f8b51ae65d1b1b1f17afa3387b908c31f
Parents: 278f1e0 569dbc0
Author: Amey Jadiye <am...@gmail.com>
Authored: Fri Jun 23 02:54:38 2017 +0530
Committer: GitHub <no...@github.com>
Committed: Fri Jun 23 02:54:38 2017 +0530
----------------------------------------------------------------------
.travis.yml | 2 +-
README.md | 2 +-
RELEASE-NOTES.txt | 42 ++-
checkstyle.xml | 4 +-
pom.xml | 17 +-
src/changes/changes.xml | 12 +-
.../java/org/apache/commons/text/CaseUtils.java | 135 ++++++++++
.../commons/text/CharacterPredicates.java | 61 +++++
.../commons/text/RandomStringGenerator.java | 26 +-
.../commons/text/translate/CsvTranslators.java | 12 +-
.../text/translate/NumericEntityEscaper.java | 23 +-
.../release-notes/RELEASE-NOTES-1.0.txt | 2 +-
.../release-notes/RELEASE-NOTES-1.1.txt | 181 +++++++++++++
src/site/xdoc/download_text.xml | 26 +-
src/site/xdoc/index.xml | 8 +-
src/site/xdoc/release-history.xml | 5 +-
.../org/apache/commons/text/CaseUtilsTest.java | 80 ++++++
.../commons/text/CharacterPredicatesTest.java | 66 +++++
.../commons/text/RandomStringGeneratorTest.java | 25 ++
.../org/apache/commons/text/StrBuilderTest.java | 257 +++++++++++++------
.../apache/commons/text/StrTokenizerTest.java | 29 ++-
.../org/apache/commons/text/WordUtilsTest.java | 3 +
.../text/translate/CsvTranslatorsTest.java | 205 +++++++--------
23 files changed, 983 insertions(+), 240 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/2dfadf4f/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/2dfadf4f/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
----------------------------------------------------------------------
diff --cc src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
index 463e767,ff50ac4..501284c
--- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
+++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
@@@ -18,9 -18,9 +18,13 @@@ package org.apache.commons.text
import org.junit.Test;
+import java.util.ArrayList;
+import java.util.List;
+
+ import static org.hamcrest.Matchers.allOf;
+ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+ import static org.hamcrest.Matchers.lessThanOrEqualTo;
++
import static org.junit.Assert.*;
/**
[3/8] [text] made a defensive copy of argument passed
Posted by ch...@apache.org.
made a defensive copy of argument passed
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/c1aabc01
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/c1aabc01
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/c1aabc01
Branch: refs/heads/master
Commit: c1aabc0172e86f4f28a0444afebda335d144b039
Parents: 278f1e0
Author: Amey Jadiye <am...@gmail.com>
Authored: Fri Jun 23 11:10:17 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Fri Jun 23 11:10:17 2017 +0530
----------------------------------------------------------------------
.../java/org/apache/commons/text/RandomStringGenerator.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/c1aabc01/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index d3d8567..358d342 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -410,7 +410,10 @@ public final class RandomStringGenerator {
* @return {@code this}, to allow method chaining
*/
public Builder selectFromList(List<Character> characterList) {
- this.characterList = characterList;
+ characterList = new ArrayList<Character>();
+ for (char c : characterList) {
+ characterList.add(c);
+ }
return this;
}
[5/8] [text] added arg list to instance variable
Posted by ch...@apache.org.
added arg list to instance variable
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/f9177e20
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/f9177e20
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/f9177e20
Branch: refs/heads/master
Commit: f9177e204d608e7fa708d57fabf0029746f7774a
Parents: b7ac42b
Author: Amey Jadiye <am...@gmail.com>
Authored: Fri Jun 23 11:22:21 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Fri Jun 23 11:22:21 2017 +0530
----------------------------------------------------------------------
.../java/org/apache/commons/text/RandomStringGenerator.java | 4 ++--
.../org/apache/commons/text/RandomStringGeneratorTest.java | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/f9177e20/src/main/java/org/apache/commons/text/RandomStringGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index 620b99e..0111746 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -434,9 +434,9 @@ public final class RandomStringGenerator {
* @return {@code this}, to allow method chaining
*/
public Builder selectFromList(List<Character> characterList) {
- characterList = new ArrayList<Character>();
+ this.characterList = new ArrayList<Character>();
for (char c : characterList) {
- characterList.add(c);
+ this.characterList.add(c);
}
return this;
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/f9177e20/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
index 501284c..3769be2 100644
--- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
+++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
@@ -232,6 +232,14 @@ public class RandomStringGeneratorTest {
assertEquals("", generator.generate(0));
}
+
+
+
+
+
+
+
+
@Test
public void testSelectFromList() {
List<Character> list = new ArrayList<Character>();
[8/8] [text] TEXT-93: Thanks Amey for update
Posted by ch...@apache.org.
TEXT-93: Thanks Amey for update
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/5e479dcd
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/5e479dcd
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/5e479dcd
Branch: refs/heads/master
Commit: 5e479dcd74dab262e5080991796395c3e29222b9
Parents: 9db7708
Author: Rob Tompkins <ch...@gmail.com>
Authored: Wed Jun 28 22:11:21 2017 -0400
Committer: Rob Tompkins <ch...@gmail.com>
Committed: Wed Jun 28 22:11:21 2017 -0400
----------------------------------------------------------------------
src/changes/changes.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/5e479dcd/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 412d1f4..41e9430 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<body>
<release version="1.2" date="tbd" description="tbd">
+ <action issue="TEXT-93" type="update" dev="chtompki" due-to="Amey Jadiye">Update RandomStringGenerator to accept a list of valid characters</action>
<action issue="TEXT-90" type="add" dev="pschumacher">Add CharacterPredicates for ASCII letters (uppercase/lowercase) and arabic numerals</action>
<action issue="TEXT-85" type="add" dev="chtompki" due-to="Arun Vinud S S">Added CaseUtils class with camel case conversion support</action>
<action issue="TEXT-91" type="add" dev="pschumacher">RandomStringGenerator should be able to generate a String with a random length</action>