More precise internal type
This commit is contained in:
parent
258406d3ee
commit
408b660813
|
@ -98,7 +98,7 @@ public class DurationFormatUtils {
|
||||||
return Stream.of(tokens).anyMatch(token -> token.getValue() == value);
|
return Stream.of(tokens).anyMatch(token -> token.getValue() == value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Object value;
|
private final CharSequence value;
|
||||||
private int count;
|
private int count;
|
||||||
private int optionalIndex = -1;
|
private int optionalIndex = -1;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class DurationFormatUtils {
|
||||||
* @param optional whether the token is optional
|
* @param optional whether the token is optional
|
||||||
* @param optionalIndex the index of the optional token within the pattern
|
* @param optionalIndex the index of the optional token within the pattern
|
||||||
*/
|
*/
|
||||||
Token(final Object value, final boolean optional, final int optionalIndex) {
|
Token(final CharSequence value, final boolean optional, final int optionalIndex) {
|
||||||
this.value = Objects.requireNonNull(value, "value");
|
this.value = Objects.requireNonNull(value, "value");
|
||||||
this.count = 1;
|
this.count = 1;
|
||||||
if (optional) {
|
if (optional) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class DurationFormatUtilsTest extends AbstractLangTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DurationFormatUtils.Token createTokenWithCount(final Object value, final int count) {
|
private DurationFormatUtils.Token createTokenWithCount(final CharSequence value, final int count) {
|
||||||
final DurationFormatUtils.Token token = new DurationFormatUtils.Token(value, false, -1);
|
final DurationFormatUtils.Token token = new DurationFormatUtils.Token(value, false, -1);
|
||||||
for (int i = 1; i < count; i++) {
|
for (int i = 1; i < count; i++) {
|
||||||
token.increment();
|
token.increment();
|
||||||
|
@ -642,9 +642,9 @@ public class DurationFormatUtilsTest extends AbstractLangTest {
|
||||||
// test failures in equals
|
// test failures in equals
|
||||||
final DurationFormatUtils.Token token = createTokenWithCount(DurationFormatUtils.y, 4);
|
final DurationFormatUtils.Token token = createTokenWithCount(DurationFormatUtils.y, 4);
|
||||||
assertNotEquals(token, new Object(), "Token equal to non-Token class. ");
|
assertNotEquals(token, new Object(), "Token equal to non-Token class. ");
|
||||||
assertNotEquals(token, createTokenWithCount(new Object(), 1), "Token equal to Token with wrong value class. ");
|
assertNotEquals(token, createTokenWithCount("", 1), "Token equal to Token with wrong value class. ");
|
||||||
assertNotEquals(token, createTokenWithCount(DurationFormatUtils.y, 1), "Token equal to Token with different count. ");
|
assertNotEquals(token, createTokenWithCount(DurationFormatUtils.y, 1), "Token equal to Token with different count. ");
|
||||||
final DurationFormatUtils.Token numToken = createTokenWithCount(Integer.valueOf(1), 4);
|
final DurationFormatUtils.Token numToken = createTokenWithCount("1", 4);
|
||||||
assertEquals(numToken, numToken, "Token with Number value not equal to itself. ");
|
assertEquals(numToken, numToken, "Token with Number value not equal to itself. ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue