From 63d88eb8db1f7a6d5924ec2a8b7f462373d5ac9a Mon Sep 17 00:00:00 2001 From: bjculkin Date: Fri, 7 Apr 2017 10:51:31 -0400 Subject: Cleanup --- .../utils/funcdata/FunctionalStringTokenizer.java | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java') 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 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 IList toList(Function transformer) { - if(transformer == null) throw new NullPointerException("Transformer must not be null"); + if (transformer == null) + throw new NullPointerException("Transformer must not be null"); IList returned = new FunctionalList<>(); @@ -151,4 +157,9 @@ public class FunctionalStringTokenizer { return returned; } + + @Override + public String toString() { + return String.format("FunctionalStringTokenizer [input=%s]", input); + } } -- cgit v1.2.3