From 85212f1738e98bd90767b0c8106fb76b38151591 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 16 Jul 2023 16:42:01 -0400 Subject: [PATCH] Make it obvious that DurationFormatUtils.Token wraps non-null values - Add Objects.requireNonNull() check - Javadoc --- .../commons/lang3/time/DurationFormatUtils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 da4b9769f..4daf47f13 100644 --- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Objects; import java.util.TimeZone; import java.util.stream.Stream; @@ -585,22 +586,21 @@ public class DurationFormatUtils { /** * Wraps a token around a value. A value would be something like a 'Y'. * - * @param value to wrap + * @param value to wrap, non-null. */ Token(final Object value) { - this.value = value; - this.count = 1; + this(value, 1); } /** * Wraps a token around a repeated number of a value, for example it would * store 'yyyy' as a value for y and a count of 4. * - * @param value to wrap - * @param count to wrap + * @param value to wrap, non-null. + * @param count to wrap. */ Token(final Object value, final int count) { - this.value = value; + this.value = Objects.requireNonNull(value, "value"); this.count = count; } @@ -623,7 +623,7 @@ public class DurationFormatUtils { /** * Gets the particular value this token represents. * - * @return Object value + * @return Object value, non-null. */ Object getValue() { return value;