diff options
| author | bjculkin <bjculkin@WIT-136XG42.wvu-ad.wvu.edu> | 2017-04-07 10:51:31 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@WIT-136XG42.wvu-ad.wvu.edu> | 2017-04-07 10:51:31 -0400 |
| commit | 63d88eb8db1f7a6d5924ec2a8b7f462373d5ac9a (patch) | |
| tree | 4a7c67b23c8e1ecb1b2f992e5dbaf3ebb48dcf6b /BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java | |
| parent | 848dc739becfa41193aff9a07c918aed91e5ef79 (diff) | |
Cleanup
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java index b7e3f30..4723bcd 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java @@ -19,7 +19,8 @@ public class FunctionalStringTokenizer { * @return A new tokenizer that splits the provided string on spaces. */ public static FunctionalStringTokenizer fromString(String strang) { - if(strang == null) throw new NullPointerException("String to tokenize must be non-null"); + if (strang == null) + throw new NullPointerException("String to tokenize must be non-null"); return new FunctionalStringTokenizer(new StringTokenizer(strang, " ")); } @@ -36,7 +37,8 @@ public class FunctionalStringTokenizer { * The string to tokenize */ public FunctionalStringTokenizer(String inp) { - if(inp == null) throw new NullPointerException("String to tokenize must be non-null"); + if (inp == null) + throw new NullPointerException("String to tokenize must be non-null"); this.input = new StringTokenizer(inp); } @@ -51,9 +53,10 @@ public class FunctionalStringTokenizer { * The set of separating tokens to use for splitting */ public FunctionalStringTokenizer(String input, String seperators) { - if(input == null) + if (input == null) throw new NullPointerException("String to tokenize must not be null"); - else if(seperators == null) throw new NullPointerException("Tokens to split on must not be null"); + else if (seperators == null) + throw new NullPointerException("Tokens to split on must not be null"); this.input = new StringTokenizer(input, seperators); } @@ -65,7 +68,8 @@ public class FunctionalStringTokenizer { * The non-functional string tokenizer to wrap */ public FunctionalStringTokenizer(StringTokenizer toWrap) { - if(toWrap == null) throw new NullPointerException("Wrapped tokenizer must not be null"); + if (toWrap == null) + throw new NullPointerException("Wrapped tokenizer must not be null"); this.input = toWrap; } @@ -77,9 +81,10 @@ public class FunctionalStringTokenizer { * The action to execute for each token */ public void forEachToken(Consumer<String> action) { - if(action == null) throw new NullPointerException("Action must not be null"); + if (action == null) + throw new NullPointerException("Action must not be null"); - while(input.hasMoreTokens()) { + while (input.hasMoreTokens()) { action.accept(input.nextToken()); } } @@ -110,7 +115,7 @@ public class FunctionalStringTokenizer { * @return The next token from the tokenizer */ public String nextToken() { - if(input.hasMoreTokens()) // Return the next available token + if (input.hasMoreTokens()) // Return the next available token return input.nextToken(); // Return no token @@ -138,7 +143,8 @@ public class FunctionalStringTokenizer { * @return A list containing all of the converted tokens. */ public <E> IList<E> toList(Function<String, E> transformer) { - if(transformer == null) throw new NullPointerException("Transformer must not be null"); + if (transformer == null) + throw new NullPointerException("Transformer must not be null"); IList<E> returned = new FunctionalList<>(); @@ -151,4 +157,9 @@ public class FunctionalStringTokenizer { return returned; } + + @Override + public String toString() { + return String.format("FunctionalStringTokenizer [input=%s]", input); + } } |
