Minor internal clean ups. Add and use constants.
This commit is contained in:
parent
b1da31ef40
commit
157ba27be7
|
@ -49,6 +49,9 @@ final class CharRange implements Iterable<Character>, Serializable {
|
|||
/** Cached toString. */
|
||||
private transient String iToString;
|
||||
|
||||
/** Empty array. */
|
||||
static final CharRange[] EMPTY_ARRAY = new CharRange[0];
|
||||
|
||||
/**
|
||||
* <p>Constructs a {@code CharRange} over a set of characters,
|
||||
* optionally negating the range.</p>
|
||||
|
|
|
@ -224,7 +224,7 @@ public class CharSet implements Serializable {
|
|||
// NOTE: This is no longer public as CharRange is no longer a public class.
|
||||
// It may be replaced when CharSet moves to Range.
|
||||
/*public*/ CharRange[] getCharRanges() {
|
||||
return set.toArray(new CharRange[0]);
|
||||
return set.toArray(CharRange.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -479,13 +479,13 @@ public class DurationFormatUtils {
|
|||
return padWithZeros ? StringUtils.leftPad(longString, count, '0') : longString;
|
||||
}
|
||||
|
||||
static final Object y = "y";
|
||||
static final Object M = "M";
|
||||
static final Object d = "d";
|
||||
static final Object H = "H";
|
||||
static final Object m = "m";
|
||||
static final Object s = "s";
|
||||
static final Object S = "S";
|
||||
static final String y = "y";
|
||||
static final String M = "M";
|
||||
static final String d = "d";
|
||||
static final String H = "H";
|
||||
static final String m = "m";
|
||||
static final String s = "s";
|
||||
static final String S = "S";
|
||||
|
||||
/**
|
||||
* Parses a classic date format string into Tokens
|
||||
|
@ -507,7 +507,7 @@ public class DurationFormatUtils {
|
|||
buffer.append(ch); // buffer can't be null if inLiteral is true
|
||||
continue;
|
||||
}
|
||||
Object value = null;
|
||||
String value = null;
|
||||
switch (ch) {
|
||||
// TODO: Need to handle escaping of '
|
||||
case '\'':
|
||||
|
@ -563,15 +563,17 @@ public class DurationFormatUtils {
|
|||
if (inLiteral) { // i.e. we have not found the end of the literal
|
||||
throw new IllegalArgumentException("Unmatched quote in format: " + format);
|
||||
}
|
||||
return list.toArray(new Token[0]);
|
||||
return list.toArray(Token.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Element that is parsed from the format pattern.
|
||||
*/
|
||||
static class Token {
|
||||
|
||||
/** Empty array. */
|
||||
private static final Token[] EMPTY_ARRAY = new Token[0];
|
||||
|
||||
/**
|
||||
* Helper method to determine if a set of tokens contain a value
|
||||
*
|
||||
|
|
|
@ -91,6 +91,9 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
// taking the value and adding (mathematically) the ASCII value for '0'.
|
||||
// So, don't change this code! It works and is very fast.
|
||||
|
||||
/** Empty array. */
|
||||
private static final Rule[] EMPTY_RULE_ARRAY = new Rule[0];
|
||||
|
||||
/**
|
||||
* Required for serialization support.
|
||||
*
|
||||
|
@ -161,7 +164,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
*/
|
||||
private void init() {
|
||||
final List<Rule> rulesList = parsePattern();
|
||||
mRules = rulesList.toArray(new Rule[0]);
|
||||
mRules = rulesList.toArray(EMPTY_RULE_ARRAY);
|
||||
|
||||
int len = 0;
|
||||
for (int i=mRules.length; --i >= 0; ) {
|
||||
|
|
Loading…
Reference in New Issue