More precise internal type

This commit is contained in:
Gary Gregory 2024-05-25 07:59:39 -04:00
parent 258406d3ee
commit 408b660813
2 changed files with 5 additions and 5 deletions

View File

@ -98,7 +98,7 @@ public class DurationFormatUtils {
return Stream.of(tokens).anyMatch(token -> token.getValue() == value);
}
private final Object value;
private final CharSequence value;
private int count;
private int optionalIndex = -1;
@ -109,7 +109,7 @@ public class DurationFormatUtils {
* @param optional whether the token is optional
* @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.count = 1;
if (optional) {

View File

@ -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);
for (int i = 1; i < count; i++) {
token.increment();
@ -642,9 +642,9 @@ public class DurationFormatUtilsTest extends AbstractLangTest {
// test failures in equals
final DurationFormatUtils.Token token = createTokenWithCount(DurationFormatUtils.y, 4);
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. ");
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. ");
}