From 408b6608133359f03fc8d5b2c7cf4abd3813ebdd Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 25 May 2024 07:59:39 -0400 Subject: [PATCH] More precise internal type --- .../org/apache/commons/lang3/time/DurationFormatUtils.java | 4 ++-- .../apache/commons/lang3/time/DurationFormatUtilsTest.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java index 417d2a592..2ecaaf70d 100644 --- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java @@ -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) { diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java index cbd4833e7..ee1d82f96 100644 --- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java @@ -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. "); }