This is an automated email from the ASF dual-hosted git repository.

garydgregory 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 043e6a3f9 Make the private instance variable 
DurationFormatUtils.Token.optionalIndex final
043e6a3f9 is described below

commit 043e6a3f9d6d22a7b1a67ce8104382eac0b0e92a
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Nov 1 17:01:37 2026 -0500

    Make the private instance variable
    DurationFormatUtils.Token.optionalIndex final
---
 .../java/org/apache/commons/lang3/time/DurationFormatUtils.java     | 6 ++----
 1 file changed, 2 insertions(+), 4 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 8569b4d4c..24d45599e 100644
--- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
@@ -112,7 +112,7 @@ static boolean containsTokenWithValue(final Token[] tokens, 
final Object value)
 
         private final CharSequence value;
         private int count;
-        private int optionalIndex = -1;
+        private final int optionalIndex;
 
         /**
          * Wraps a token around a value. A value would be something like a 'Y'.
@@ -124,9 +124,7 @@ static boolean containsTokenWithValue(final Token[] tokens, 
final Object value)
         Token(final CharSequence value, final boolean optional, final int 
optionalIndex) {
             this.value = Objects.requireNonNull(value, "value");
             this.count = 1;
-            if (optional) {
-                this.optionalIndex = optionalIndex;
-            }
+            this.optionalIndex = optional ? optionalIndex : -1;
         }
 
         /**

Reply via email to