exceptionfactory commented on code in PR #11313:
URL: https://github.com/apache/nifi/pull/11313#discussion_r3616068571


##########
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java:
##########
@@ -298,4 +303,54 @@ public static Instant parseToInstant(final 
DateTimeFormatter formatter, final St
         final OffsetDateTime offsetDateTime = OffsetDateTime.of(localDateTime, 
zoneOffset);
         return offsetDateTime.toInstant();
     }
+
+    /**
+     * Format a value of ChronoUnit into a word representation.
+     * Does not handle estimated ChronoUnit values.
+     * For anything greater than {@link ChronoUnit#DAYS}, use {@link 
#formatDurationToWords(Duration)}.
+     *
+     * @param value the number of the given {@link ChronoUnit} to measure
+     * @param unit {@link ChronoUnit} that the value represents
+     * @return String representation of the given value and unit
+     * @throws UnsupportedTemporalTypeException if the unit is not supported 
({@link ChronoUnit#isDurationEstimated()} == true)
+     */
+    public static String formatDurationToWords(long value, ChronoUnit unit) 
throws UnsupportedTemporalTypeException {
+        return formatDurationToWords(Duration.ZERO.plus(value, unit));
+    }
+
+    /**
+     * Format a Duration using words (days, hours, minutes, seconds, ns) where 
all lower units are
+     *   included once a non-zero unit is found. Unit plurality is preserved.
+     * Maximum resolution is in terms of days.
+     *
+     * @param source duration to convert to words
+     * @return String representation of the given duration
+     */
+    public static String formatDurationToWords(Duration source) {
+        long days = source.toDaysPart();
+        long hours = source.toHoursPart();
+        long minutes = source.toMinutesPart();
+        int seconds = source.toSecondsPart();
+        int nanos = source.toNanosPart();
+
+        List<String> parts = new ArrayList<>();

Review Comment:
   The `final` keyword should be used across this method.



##########
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java:
##########
@@ -298,4 +303,54 @@ public static Instant parseToInstant(final 
DateTimeFormatter formatter, final St
         final OffsetDateTime offsetDateTime = OffsetDateTime.of(localDateTime, 
zoneOffset);
         return offsetDateTime.toInstant();
     }
+
+    /**
+     * Format a value of ChronoUnit into a word representation.
+     * Does not handle estimated ChronoUnit values.
+     * For anything greater than {@link ChronoUnit#DAYS}, use {@link 
#formatDurationToWords(Duration)}.
+     *
+     * @param value the number of the given {@link ChronoUnit} to measure
+     * @param unit {@link ChronoUnit} that the value represents
+     * @return String representation of the given value and unit
+     * @throws UnsupportedTemporalTypeException if the unit is not supported 
({@link ChronoUnit#isDurationEstimated()} == true)
+     */
+    public static String formatDurationToWords(long value, ChronoUnit unit) 
throws UnsupportedTemporalTypeException {

Review Comment:
   The arguments should have the `final` keyword.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to