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


The following commit(s) were added to refs/heads/master by this push:
     new 85212f173 Make it obvious that DurationFormatUtils.Token wraps 
non-null values
85212f173 is described below

commit 85212f1738e98bd90767b0c8106fb76b38151591
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Jul 16 16:42:01 2023 -0400

    Make it obvious that DurationFormatUtils.Token wraps non-null values
    
    - Add Objects.requireNonNull() check
    - Javadoc
---
 .../org/apache/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;

Reply via email to