You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/05/25 13:15:16 UTC
(commons-lang) 01/03: More precise internal type
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 408b6608133359f03fc8d5b2c7cf4abd3813ebdd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat May 25 07:59:39 2024 -0400
More precise internal type
---
.../java/org/apache/commons/lang3/time/DurationFormatUtils.java | 4 ++--
.../java/org/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. ");
}