Skip to content

Commit c973eb7

Browse files
committed
Initialize in declaration
1 parent 5c532bd commit c973eb7

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/main/java/org/apache/commons/text/StringTokenizer.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,26 @@
9494
public class StringTokenizer implements ListIterator<String>, Cloneable {
9595

9696
/** Comma separated values tokenizer internal variable. */
97-
private static final StringTokenizer CSV_TOKENIZER_PROTOTYPE;
97+
// @formatter:off
98+
private static final StringTokenizer CSV_TOKENIZER_PROTOTYPE = new StringTokenizer()
99+
.setDelimiterMatcher(StringMatcherFactory.INSTANCE.commaMatcher())
100+
.setQuoteMatcher(StringMatcherFactory.INSTANCE.doubleQuoteMatcher())
101+
.setIgnoredMatcher(StringMatcherFactory.INSTANCE.noneMatcher())
102+
.setTrimmerMatcher(StringMatcherFactory.INSTANCE.trimMatcher())
103+
.setEmptyTokenAsNull(false)
104+
.setIgnoreEmptyTokens(false);
105+
// @formatter:on
98106

99107
/** Tab separated values tokenizer internal variable. */
100-
private static final StringTokenizer TSV_TOKENIZER_PROTOTYPE;
101-
102-
static {
103-
CSV_TOKENIZER_PROTOTYPE = new StringTokenizer();
104-
CSV_TOKENIZER_PROTOTYPE.setDelimiterMatcher(StringMatcherFactory.INSTANCE.commaMatcher());
105-
CSV_TOKENIZER_PROTOTYPE.setQuoteMatcher(StringMatcherFactory.INSTANCE.doubleQuoteMatcher());
106-
CSV_TOKENIZER_PROTOTYPE.setIgnoredMatcher(StringMatcherFactory.INSTANCE.noneMatcher());
107-
CSV_TOKENIZER_PROTOTYPE.setTrimmerMatcher(StringMatcherFactory.INSTANCE.trimMatcher());
108-
CSV_TOKENIZER_PROTOTYPE.setEmptyTokenAsNull(false);
109-
CSV_TOKENIZER_PROTOTYPE.setIgnoreEmptyTokens(false);
110-
111-
TSV_TOKENIZER_PROTOTYPE = new StringTokenizer();
112-
TSV_TOKENIZER_PROTOTYPE.setDelimiterMatcher(StringMatcherFactory.INSTANCE.tabMatcher());
113-
TSV_TOKENIZER_PROTOTYPE.setQuoteMatcher(StringMatcherFactory.INSTANCE.doubleQuoteMatcher());
114-
TSV_TOKENIZER_PROTOTYPE.setIgnoredMatcher(StringMatcherFactory.INSTANCE.noneMatcher());
115-
TSV_TOKENIZER_PROTOTYPE.setTrimmerMatcher(StringMatcherFactory.INSTANCE.trimMatcher());
116-
TSV_TOKENIZER_PROTOTYPE.setEmptyTokenAsNull(false);
117-
TSV_TOKENIZER_PROTOTYPE.setIgnoreEmptyTokens(false);
118-
}
108+
// @formatter:off
109+
private static final StringTokenizer TSV_TOKENIZER_PROTOTYPE = new StringTokenizer()
110+
.setDelimiterMatcher(StringMatcherFactory.INSTANCE.tabMatcher())
111+
.setQuoteMatcher(StringMatcherFactory.INSTANCE.doubleQuoteMatcher())
112+
.setIgnoredMatcher(StringMatcherFactory.INSTANCE.noneMatcher())
113+
.setTrimmerMatcher(StringMatcherFactory.INSTANCE.trimMatcher())
114+
.setEmptyTokenAsNull(false)
115+
.setIgnoreEmptyTokens(false);
116+
// @formatter:on
119117

120118
/**
121119
* Returns a clone of {@code CSV_TOKENIZER_PROTOTYPE}.

0 commit comments

Comments
 (0)