elharo commented on code in PR #450: URL: https://github.com/apache/commons-text/pull/450#discussion_r1299406284
########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii Review Comment: ASCII ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii + * letters are encountered. The upppercase letter is considered part of the new token. The very + * first character of the string is an exception to this rule and must be a lowercase ascii + * character. This method places no other restrictions on the content of the string. <br> + * Note: This method should never produce empty tokens. + * </p> + * @param string Camel Case formatted string to parse + * @return list of tokens parsed from the string + */ + @Override + public List<String> parse(String string) { + List<String> tokens = new LinkedList<>(); + if (string.length() == 0) { + return tokens; + } + if (!CharUtils.isAsciiAlphaLower(string.charAt(0))) { + throw new IllegalArgumentException("Character '" + string.charAt(0) + "' at index 0 must be an ascii lowercase letter"); + } + /*StringBuilder tokenBuilder = new StringBuilder(); Review Comment: don't comment out code; remove it ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii + * letters are encountered. The upppercase letter is considered part of the new token. The very + * first character of the string is an exception to this rule and must be a lowercase ascii Review Comment: Why? seems to be an unnecessary limitation ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii + * letters are encountered. The upppercase letter is considered part of the new token. The very + * first character of the string is an exception to this rule and must be a lowercase ascii + * character. This method places no other restrictions on the content of the string. <br> + * Note: This method should never produce empty tokens. + * </p> + * @param string Camel Case formatted string to parse Review Comment: camel case ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. Review Comment: incomplete sentence ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { Review Comment: private ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii + * letters are encountered. The upppercase letter is considered part of the new token. The very + * first character of the string is an exception to this rule and must be a lowercase ascii + * character. This method places no other restrictions on the content of the string. <br> + * Note: This method should never produce empty tokens. + * </p> + * @param string Camel Case formatted string to parse + * @return list of tokens parsed from the string + */ + @Override + public List<String> parse(String string) { + List<String> tokens = new LinkedList<>(); Review Comment: array lists almost always perform better ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii + * letters are encountered. The upppercase letter is considered part of the new token. The very + * first character of the string is an exception to this rule and must be a lowercase ascii + * character. This method places no other restrictions on the content of the string. <br> + * Note: This method should never produce empty tokens. + * </p> + * @param string Camel Case formatted string to parse + * @return list of tokens parsed from the string + */ + @Override + public List<String> parse(String string) { + List<String> tokens = new LinkedList<>(); + if (string.length() == 0) { + return tokens; + } + if (!CharUtils.isAsciiAlphaLower(string.charAt(0))) { + throw new IllegalArgumentException("Character '" + string.charAt(0) + "' at index 0 must be an ascii lowercase letter"); + } + /*StringBuilder tokenBuilder = new StringBuilder(); + for (int i = 0; i < string.length(); i++) { + char c = string.charAt(i); + if (CharUtils.isAsciiAlphaUpper(c)) { + tokens.add(tokenBuilder.toString()); + tokenBuilder.setLength(0); + } + tokenBuilder.append(c); + } + tokens.add(tokenBuilder.toString());*/ + int strLen = string.length(); + int[] tokenCodePoints = new int[strLen]; + int tokenCodePointsOffset = 0; + for (int i = 0; i < string.length();) { + final int codePoint = string.codePointAt(i); + if (CharUtils.isAsciiAlphaUpper((char) codePoint)) { + if (tokenCodePointsOffset > 0) { + tokens.add(new String(tokenCodePoints, 0, tokenCodePointsOffset)); + tokenCodePoints = new int[strLen]; + tokenCodePointsOffset = 0; + } + tokenCodePoints[tokenCodePointsOffset++] = codePoint; + i += Character.charCount(codePoint); + } else { + tokenCodePoints[tokenCodePointsOffset++] = codePoint; + i += Character.charCount(codePoint); + } + } + tokens.add(new String(tokenCodePoints, 0, tokenCodePointsOffset)); + return tokens; + } + + /** + * Formats tokens into a Camel Case string. + * <p> + * Iterates each token and creates a camel case formatted string. Each token must begin with an + * ascii letter, which will be forced uppercase in the output, except for the very first token, Review Comment: forced --> converted to ########## src/main/java/org/apache/commons/text/cases/Case.java: ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.List; + +/** + * Handles formatting and parsing tokens to/from a String. For most implementations tokens returned + * by the parse method should abide by any restrictions present in the format method. i.e. Calling + * format() with the results of a call to parse() on the same Case instance should return a + * matching String. + * + * @since 1.11 + */ +public interface Case { + + /** + * Formats a set of tokens into a string. The tokens do not necessarily have to meet the syntax + * requirements of the Case. The documentation for each implementation should specify what input + * is supported. + * + * @param tokens string tokens to be formatted by this Case + * @return the formatted string + */ + String format(Iterable<String> tokens); Review Comment: This needs documentation of exceptions thrown under which condtions ########## src/main/java/org/apache/commons/text/cases/CamelCase.java: ########## @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.CharUtils; +import org.apache.commons.lang3.StringUtils; + +/** + * Case implementation that parses and formats strings of the form 'myCamelCase' + * <p> + * This case separates tokens on uppercase ascii alpha characters, with the exception + * that the first token begin with a lowercase ascii alpha character. + * </p> + */ +public class CamelCase implements Case { + + /** constant reuseable instance of this case. */ + public static final CamelCase INSTANCE = new CamelCase(); + + /** + * Constructs new CamelCase instance. + */ + public CamelCase() { + super(); + } + + /** + * Parses string tokens from a Camel Case formatted string. + * <p> + * Parses each character of the string parameter and creates new tokens when uppercase ascii + * letters are encountered. The upppercase letter is considered part of the new token. The very + * first character of the string is an exception to this rule and must be a lowercase ascii + * character. This method places no other restrictions on the content of the string. <br> + * Note: This method should never produce empty tokens. + * </p> + * @param string Camel Case formatted string to parse + * @return list of tokens parsed from the string + */ + @Override + public List<String> parse(String string) { + List<String> tokens = new LinkedList<>(); + if (string.length() == 0) { + return tokens; + } + if (!CharUtils.isAsciiAlphaLower(string.charAt(0))) { + throw new IllegalArgumentException("Character '" + string.charAt(0) + "' at index 0 must be an ascii lowercase letter"); + } + /*StringBuilder tokenBuilder = new StringBuilder(); + for (int i = 0; i < string.length(); i++) { + char c = string.charAt(i); + if (CharUtils.isAsciiAlphaUpper(c)) { + tokens.add(tokenBuilder.toString()); + tokenBuilder.setLength(0); + } + tokenBuilder.append(c); + } + tokens.add(tokenBuilder.toString());*/ + int strLen = string.length(); + int[] tokenCodePoints = new int[strLen]; + int tokenCodePointsOffset = 0; + for (int i = 0; i < string.length();) { + final int codePoint = string.codePointAt(i); + if (CharUtils.isAsciiAlphaUpper((char) codePoint)) { + if (tokenCodePointsOffset > 0) { + tokens.add(new String(tokenCodePoints, 0, tokenCodePointsOffset)); + tokenCodePoints = new int[strLen]; + tokenCodePointsOffset = 0; + } + tokenCodePoints[tokenCodePointsOffset++] = codePoint; + i += Character.charCount(codePoint); + } else { + tokenCodePoints[tokenCodePointsOffset++] = codePoint; + i += Character.charCount(codePoint); + } + } + tokens.add(new String(tokenCodePoints, 0, tokenCodePointsOffset)); + return tokens; + } + + /** + * Formats tokens into a Camel Case string. + * <p> + * Iterates each token and creates a camel case formatted string. Each token must begin with an Review Comment: how do you iterate a token? ########## src/main/java/org/apache/commons/text/cases/Case.java: ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.List; + +/** + * Handles formatting and parsing tokens to/from a String. For most implementations tokens returned + * by the parse method should abide by any restrictions present in the format method. i.e. Calling + * format() with the results of a call to parse() on the same Case instance should return a + * matching String. + * + * @since 1.11 + */ +public interface Case { + + /** + * Formats a set of tokens into a string. The tokens do not necessarily have to meet the syntax + * requirements of the Case. The documentation for each implementation should specify what input + * is supported. + * + * @param tokens string tokens to be formatted by this Case + * @return the formatted string + */ + String format(Iterable<String> tokens); + + /** + * Parses a string into a series of tokens. The string must abide by certain restrictions, + * dependent on each Case implementation. + * + * @param string The string to be parsed by the Case into a list of tokens + * @return The list of parsed tokens Review Comment: use Oracle's rules for formatting doc comments ########## src/test/java/org/apache/commons/text/cases/CasesTest.java: ########## @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CasesTest { + + @Test + public void testDelimiterCharacterException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> KebabCase.INSTANCE.format(Arrays.asList("a", "-"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> SnakeCase.INSTANCE.format(Arrays.asList("a", "_"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(null, ",")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[1], null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[0], ",")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[0], "")); + } + + @Test + public void testKebabCase() { + assertFormatAndParse(KebabCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(KebabCase.INSTANCE, "my-Tokens-123-a1", Arrays.asList("my", "Tokens", "123", "a1")); + assertFormatAndParse(KebabCase.INSTANCE, "blank--token", Arrays.asList("blank", "", "token")); + } + + @Test + public void testUtf32() { + assertFormatAndParse(KebabCase.INSTANCE, "\uD800\uDF00-\uD800\uDF01\uD800\uDF14-\uD800\uDF02\uD800\uDF03", + Arrays.asList("\uD800\uDF00", "\uD800\uDF01\uD800\uDF14", "\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(SnakeCase.INSTANCE, "\uD800\uDF00_\uD800\uDF01\uD800\uDF14_\uD800\uDF02\uD800\uDF03", + Arrays.asList("\uD800\uDF00", "\uD800\uDF01\uD800\uDF14", "\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(PascalCase.INSTANCE, "A\uD800\uDF00B\uD800\uDF01\uD800\uDF14C\uD800\uDF02\uD800\uDF03", + Arrays.asList("A\uD800\uDF00", "B\uD800\uDF01\uD800\uDF14", "C\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(CamelCase.INSTANCE, "a\uD800\uDF00B\uD800\uDF01\uD800\uDF14C\uD800\uDF02\uD800\uDF03", + Arrays.asList("a\uD800\uDF00", "B\uD800\uDF01\uD800\uDF14", "C\uD800\uDF02\uD800\uDF03")); + } + + @Test + public void testSnakeCase() { + assertFormatAndParse(SnakeCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(SnakeCase.INSTANCE, "my_Tokens_123_a1", Arrays.asList("my", "Tokens", "123", "a1")); + assertFormatAndParse(SnakeCase.INSTANCE, "blank__token", Arrays.asList("blank", "", "token")); + } + + @Test + public void testPascalCase() { + + assertFormatAndParse(PascalCase.INSTANCE, "MyVarName", Arrays.asList("My", "Var", "Name")); + assertFormatAndParse(PascalCase.INSTANCE, "MyTokensA1D", Arrays.asList("My", "Tokens", "A1", "D")); + assertFormatAndParse(PascalCase.INSTANCE, "", Arrays.asList()); + + // first character must be ascii alpha upper + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.parse("lowerFirst")); + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(Arrays.asList("1"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(Arrays.asList(""))); + } + + @Test + public void testCamelCase() { + + assertFormatAndParse(CamelCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(CamelCase.INSTANCE, "myTokensAbc123", Arrays.asList("my", "Tokens", "Abc123")); + assertFormatAndParse(CamelCase.INSTANCE, "specChar-Token+", Arrays.asList("spec", "Char-", "Token+")); + + // empty token not supported + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(Arrays.asList("a", "b", ""))); + // must begin with ascii alpha + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(Arrays.asList("a", "1b"))); + // must begin with ascii alpha lower + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.parse("MyTokens")); + } + + @Test + public void testConversionsDelimited() { + + List<String> tokens = Arrays.asList("My", "var", "NAME", "mIXED", "a1", "12", ""); + + String kebabString = "My-var-NAME-mIXED-a1-12-"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + String snakeString = "My_var_NAME_mIXED_a1_12_"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + } + + @Test + public void testConversions() { + + List<String> tokens = Arrays.asList("My", "var", "NAME", "mIXED", "a1", "c|=+"); + + String kebabString = "My-var-NAME-mIXED-a1-c|=+"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + String snakeString = "My_var_NAME_mIXED_a1_c|=+"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + + String camelString = "myVarNameMixedA1C|=+"; + assertFormatAndParse(CamelCase.INSTANCE, camelString, tokens, true); + + String pascalString = "MyVarNameMixedA1C|=+"; + assertFormatAndParse(PascalCase.INSTANCE, pascalString, tokens, true); + + } + + @Test + public void testEmptyTokens() { + List<String> tokens = Arrays.asList("HAS", "", "empty", "Tokens", ""); + + String snakeString = "HAS__empty_Tokens_"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + + String kebabString = "HAS--empty-Tokens-"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(tokens)); + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(tokens)); + } + + public void assertFormatAndParse(Case caseInstance, String string, List<String> tokens) { + assertFormatAndParse(caseInstance, string, tokens, false); + } + + /** + * Test Util method for ensuring that a case instance produces the expecting string and tokens + * upon formatting and parsing + * + * @param case Instance the case instance to use + * @param string the expected formatted string + * @param tokens the expected tokens + * @param caseInsensitive whether to not to validate tokens case insensitively + */ + public void assertFormatAndParse(Case caseInstance, String string, List<String> tokens, Boolean caseInsensitive) { + List<String> parsedTokens = caseInstance.parse(string); + if (caseInsensitive) { + assertEqualsIgnoreCase(tokens, parsedTokens); + } else { + Assertions.assertEquals(tokens, parsedTokens); + } + String formatted = caseInstance.format(tokens); + Assertions.assertEquals(string, formatted); + } + + public void assertEqualsIgnoreCase(List<String> expected, List<String> actual) { Review Comment: private ########## src/main/java/org/apache/commons/text/cases/SnakeCase.java: ########## @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +/** + * Case implementation which parses and formats strings of the form 'my_snake_string' + * <p> + * SnakeCase is a delimited case where the delimiter is the underscore character '_'. + * </p> + */ +public class SnakeCase extends DelimitedCase { + + /** constant for delimiter. */ + public static final char DELIMITER = '_'; Review Comment: private ########## src/main/java/org/apache/commons/text/cases/SnakeCase.java: ########## @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +/** + * Case implementation which parses and formats strings of the form 'my_snake_string' + * <p> + * SnakeCase is a delimited case where the delimiter is the underscore character '_'. + * </p> + */ +public class SnakeCase extends DelimitedCase { + + /** constant for delimiter. */ + public static final char DELIMITER = '_'; + + /** constant reuseable instance of this case. */ + public static final SnakeCase INSTANCE = new SnakeCase(); + + /** + * Constructs a new SnakeCase instance. + */ + public SnakeCase() { Review Comment: private ########## src/test/java/org/apache/commons/text/cases/CasesTest.java: ########## @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CasesTest { + + @Test + public void testDelimiterCharacterException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> KebabCase.INSTANCE.format(Arrays.asList("a", "-"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> SnakeCase.INSTANCE.format(Arrays.asList("a", "_"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(null, ",")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[1], null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[0], ",")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[0], "")); + } + + @Test + public void testKebabCase() { + assertFormatAndParse(KebabCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(KebabCase.INSTANCE, "my-Tokens-123-a1", Arrays.asList("my", "Tokens", "123", "a1")); + assertFormatAndParse(KebabCase.INSTANCE, "blank--token", Arrays.asList("blank", "", "token")); + } + + @Test + public void testUtf32() { + assertFormatAndParse(KebabCase.INSTANCE, "\uD800\uDF00-\uD800\uDF01\uD800\uDF14-\uD800\uDF02\uD800\uDF03", + Arrays.asList("\uD800\uDF00", "\uD800\uDF01\uD800\uDF14", "\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(SnakeCase.INSTANCE, "\uD800\uDF00_\uD800\uDF01\uD800\uDF14_\uD800\uDF02\uD800\uDF03", + Arrays.asList("\uD800\uDF00", "\uD800\uDF01\uD800\uDF14", "\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(PascalCase.INSTANCE, "A\uD800\uDF00B\uD800\uDF01\uD800\uDF14C\uD800\uDF02\uD800\uDF03", + Arrays.asList("A\uD800\uDF00", "B\uD800\uDF01\uD800\uDF14", "C\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(CamelCase.INSTANCE, "a\uD800\uDF00B\uD800\uDF01\uD800\uDF14C\uD800\uDF02\uD800\uDF03", + Arrays.asList("a\uD800\uDF00", "B\uD800\uDF01\uD800\uDF14", "C\uD800\uDF02\uD800\uDF03")); + } + + @Test + public void testSnakeCase() { + assertFormatAndParse(SnakeCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(SnakeCase.INSTANCE, "my_Tokens_123_a1", Arrays.asList("my", "Tokens", "123", "a1")); + assertFormatAndParse(SnakeCase.INSTANCE, "blank__token", Arrays.asList("blank", "", "token")); + } + + @Test + public void testPascalCase() { + + assertFormatAndParse(PascalCase.INSTANCE, "MyVarName", Arrays.asList("My", "Var", "Name")); + assertFormatAndParse(PascalCase.INSTANCE, "MyTokensA1D", Arrays.asList("My", "Tokens", "A1", "D")); + assertFormatAndParse(PascalCase.INSTANCE, "", Arrays.asList()); + + // first character must be ascii alpha upper + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.parse("lowerFirst")); + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(Arrays.asList("1"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(Arrays.asList(""))); + } + + @Test + public void testCamelCase() { + + assertFormatAndParse(CamelCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(CamelCase.INSTANCE, "myTokensAbc123", Arrays.asList("my", "Tokens", "Abc123")); + assertFormatAndParse(CamelCase.INSTANCE, "specChar-Token+", Arrays.asList("spec", "Char-", "Token+")); + + // empty token not supported + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(Arrays.asList("a", "b", ""))); + // must begin with ascii alpha + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(Arrays.asList("a", "1b"))); + // must begin with ascii alpha lower + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.parse("MyTokens")); + } + + @Test + public void testConversionsDelimited() { + + List<String> tokens = Arrays.asList("My", "var", "NAME", "mIXED", "a1", "12", ""); + + String kebabString = "My-var-NAME-mIXED-a1-12-"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + String snakeString = "My_var_NAME_mIXED_a1_12_"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + } + + @Test + public void testConversions() { + + List<String> tokens = Arrays.asList("My", "var", "NAME", "mIXED", "a1", "c|=+"); + + String kebabString = "My-var-NAME-mIXED-a1-c|=+"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + String snakeString = "My_var_NAME_mIXED_a1_c|=+"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + + String camelString = "myVarNameMixedA1C|=+"; + assertFormatAndParse(CamelCase.INSTANCE, camelString, tokens, true); + + String pascalString = "MyVarNameMixedA1C|=+"; + assertFormatAndParse(PascalCase.INSTANCE, pascalString, tokens, true); + + } + + @Test + public void testEmptyTokens() { + List<String> tokens = Arrays.asList("HAS", "", "empty", "Tokens", ""); + + String snakeString = "HAS__empty_Tokens_"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + + String kebabString = "HAS--empty-Tokens-"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(tokens)); + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(tokens)); + } + + public void assertFormatAndParse(Case caseInstance, String string, List<String> tokens) { + assertFormatAndParse(caseInstance, string, tokens, false); + } + + /** + * Test Util method for ensuring that a case instance produces the expecting string and tokens + * upon formatting and parsing + * + * @param case Instance the case instance to use + * @param string the expected formatted string + * @param tokens the expected tokens + * @param caseInsensitive whether to not to validate tokens case insensitively + */ + public void assertFormatAndParse(Case caseInstance, String string, List<String> tokens, Boolean caseInsensitive) { + List<String> parsedTokens = caseInstance.parse(string); + if (caseInsensitive) { + assertEqualsIgnoreCase(tokens, parsedTokens); + } else { + Assertions.assertEquals(tokens, parsedTokens); + } + String formatted = caseInstance.format(tokens); + Assertions.assertEquals(string, formatted); + } + + public void assertEqualsIgnoreCase(List<String> expected, List<String> actual) { + Assertions.assertEquals(expected.size(), actual.size()); + Iterator<String> itEx = expected.iterator(); Review Comment: This can be a loop variable ########## src/test/java/org/apache/commons/text/cases/CasesTest.java: ########## @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.text.cases; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CasesTest { + + @Test + public void testDelimiterCharacterException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> KebabCase.INSTANCE.format(Arrays.asList("a", "-"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> SnakeCase.INSTANCE.format(Arrays.asList("a", "_"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(null, ",")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[1], null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[0], ",")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DelimitedCase(new char[0], "")); + } + + @Test + public void testKebabCase() { + assertFormatAndParse(KebabCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(KebabCase.INSTANCE, "my-Tokens-123-a1", Arrays.asList("my", "Tokens", "123", "a1")); + assertFormatAndParse(KebabCase.INSTANCE, "blank--token", Arrays.asList("blank", "", "token")); + } + + @Test + public void testUtf32() { + assertFormatAndParse(KebabCase.INSTANCE, "\uD800\uDF00-\uD800\uDF01\uD800\uDF14-\uD800\uDF02\uD800\uDF03", + Arrays.asList("\uD800\uDF00", "\uD800\uDF01\uD800\uDF14", "\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(SnakeCase.INSTANCE, "\uD800\uDF00_\uD800\uDF01\uD800\uDF14_\uD800\uDF02\uD800\uDF03", + Arrays.asList("\uD800\uDF00", "\uD800\uDF01\uD800\uDF14", "\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(PascalCase.INSTANCE, "A\uD800\uDF00B\uD800\uDF01\uD800\uDF14C\uD800\uDF02\uD800\uDF03", + Arrays.asList("A\uD800\uDF00", "B\uD800\uDF01\uD800\uDF14", "C\uD800\uDF02\uD800\uDF03")); + assertFormatAndParse(CamelCase.INSTANCE, "a\uD800\uDF00B\uD800\uDF01\uD800\uDF14C\uD800\uDF02\uD800\uDF03", + Arrays.asList("a\uD800\uDF00", "B\uD800\uDF01\uD800\uDF14", "C\uD800\uDF02\uD800\uDF03")); + } + + @Test + public void testSnakeCase() { + assertFormatAndParse(SnakeCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(SnakeCase.INSTANCE, "my_Tokens_123_a1", Arrays.asList("my", "Tokens", "123", "a1")); + assertFormatAndParse(SnakeCase.INSTANCE, "blank__token", Arrays.asList("blank", "", "token")); + } + + @Test + public void testPascalCase() { + + assertFormatAndParse(PascalCase.INSTANCE, "MyVarName", Arrays.asList("My", "Var", "Name")); + assertFormatAndParse(PascalCase.INSTANCE, "MyTokensA1D", Arrays.asList("My", "Tokens", "A1", "D")); + assertFormatAndParse(PascalCase.INSTANCE, "", Arrays.asList()); + + // first character must be ascii alpha upper + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.parse("lowerFirst")); + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(Arrays.asList("1"))); + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(Arrays.asList(""))); + } + + @Test + public void testCamelCase() { + + assertFormatAndParse(CamelCase.INSTANCE, "", Arrays.asList()); + assertFormatAndParse(CamelCase.INSTANCE, "myTokensAbc123", Arrays.asList("my", "Tokens", "Abc123")); + assertFormatAndParse(CamelCase.INSTANCE, "specChar-Token+", Arrays.asList("spec", "Char-", "Token+")); + + // empty token not supported + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(Arrays.asList("a", "b", ""))); + // must begin with ascii alpha + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(Arrays.asList("a", "1b"))); + // must begin with ascii alpha lower + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.parse("MyTokens")); + } + + @Test + public void testConversionsDelimited() { + + List<String> tokens = Arrays.asList("My", "var", "NAME", "mIXED", "a1", "12", ""); + + String kebabString = "My-var-NAME-mIXED-a1-12-"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + String snakeString = "My_var_NAME_mIXED_a1_12_"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + } + + @Test + public void testConversions() { + + List<String> tokens = Arrays.asList("My", "var", "NAME", "mIXED", "a1", "c|=+"); + + String kebabString = "My-var-NAME-mIXED-a1-c|=+"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + String snakeString = "My_var_NAME_mIXED_a1_c|=+"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + + String camelString = "myVarNameMixedA1C|=+"; + assertFormatAndParse(CamelCase.INSTANCE, camelString, tokens, true); + + String pascalString = "MyVarNameMixedA1C|=+"; + assertFormatAndParse(PascalCase.INSTANCE, pascalString, tokens, true); + + } + + @Test + public void testEmptyTokens() { + List<String> tokens = Arrays.asList("HAS", "", "empty", "Tokens", ""); + + String snakeString = "HAS__empty_Tokens_"; + assertFormatAndParse(SnakeCase.INSTANCE, snakeString, tokens); + + String kebabString = "HAS--empty-Tokens-"; + assertFormatAndParse(KebabCase.INSTANCE, kebabString, tokens); + + Assertions.assertThrows(IllegalArgumentException.class, () -> PascalCase.INSTANCE.format(tokens)); + Assertions.assertThrows(IllegalArgumentException.class, () -> CamelCase.INSTANCE.format(tokens)); + } + + public void assertFormatAndParse(Case caseInstance, String string, List<String> tokens) { + assertFormatAndParse(caseInstance, string, tokens, false); + } + + /** + * Test Util method for ensuring that a case instance produces the expecting string and tokens + * upon formatting and parsing + * + * @param case Instance the case instance to use + * @param string the expected formatted string + * @param tokens the expected tokens + * @param caseInsensitive whether to not to validate tokens case insensitively + */ + public void assertFormatAndParse(Case caseInstance, String string, List<String> tokens, Boolean caseInsensitive) { Review Comment: private -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org