garydgregory commented on a change in pull request #124:
URL: https://github.com/apache/commons-io/pull/124#discussion_r453320087



##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1690,6 +1810,119 @@ public static boolean isFileOlder(final File file, 
final long timeMillis) {
         return file.lastModified() < timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is older than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * before the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */
+    public static boolean isFileOlder(final File file, final Instant instant) {
+        if (instant == null) {
+            throw new IllegalArgumentException("No specified instant");
+        }
+        return isFileOlder(file, instant.toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is older than the specified
+     * <code>ZonedDateTime</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param zonedDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * before the given <code>ZonedDateTime</code>.
+     * @throws IllegalArgumentException if the file or zoned date time is 
{@code null}
+     */
+    public static boolean isFileOlder(final File file, final ZonedDateTime 
zonedDateTime) {
+        if (zonedDateTime == null) {
+            throw new IllegalArgumentException("No specified zonedDateTime");
+        }
+        return isFileOlder(file, zonedDateTime.toInstant());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is older than the specified
+     * <code>LocalDateTime</code> at the system-default time zone.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param localDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * before the given <code>LocalDateTime</code> at the system-default time 
zone.
+     * @throws IllegalArgumentException if the file or local date time is 
{@code null}
+     */
+    public static boolean isFileOlder(final File file, final LocalDateTime 
localDateTime) {
+        return isFileOlder(file, localDateTime, ZoneId.systemDefault());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is older than the specified
+     * <code>LocalDateTime</code> at the specified <code>ZoneId</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param localDateTime the date reference, must not be {@code null}
+     * @param zoneId        the time zone, must not be {@code null}

Review comment:
       IMO, either:
   - Say nothing instead of "must not be {@code null}" since this information 
duplicates @throws, or
   - Be specific: "the time zone,  or throws {@code NullPointerException} if 
{@code null}."

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1624,6 +1631,119 @@ public static boolean isFileNewer(final File file, 
final long timeMillis) {
         return file.lastModified() > timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */

Review comment:
       New public APIs need `@since` tags.

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1624,6 +1631,119 @@ public static boolean isFileNewer(final File file, 
final long timeMillis) {
         return file.lastModified() > timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final Instant instant) {
+        if (instant == null) {
+            throw new IllegalArgumentException("No specified instant");
+        }
+        return isFileNewer(file, instant.toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>ZonedDateTime</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param zonedDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>ZonedDateTime</code>.
+     * @throws IllegalArgumentException if the file or zoned date time is 
{@code null}
+     */
+    public static boolean isFileNewer(final File file, final ZonedDateTime 
zonedDateTime) {
+        if (zonedDateTime == null) {
+            throw new IllegalArgumentException("No specified zonedDateTime");
+        }
+        return isFileNewer(file, zonedDateTime.toInstant());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>LocalDateTime</code> at the system-default time zone.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param localDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>LocalDateTime</code> at the system-default time 
zone.
+     * @throws IllegalArgumentException if the file or local date time is 
{@code null}
+     */
+    public static boolean isFileNewer(final File file, final LocalDateTime 
localDateTime) {
+        return isFileNewer(file, localDateTime, ZoneId.systemDefault());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>LocalDateTime</code> at the specified <code>ZoneId</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param localDateTime the date reference, must not be {@code null}
+     * @param zoneId        the time zone, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>LocalDateTime</code> at the given 
<code>ZoneId</code>.
+     * @throws IllegalArgumentException if the file, local date time or zone 
ID is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final LocalDateTime 
localDateTime, final ZoneId zoneId) {

Review comment:
       Why is this API typed to a `LocalDateTime` instead of 
`ChronoLocalDateTime`?

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -83,6 +88,8 @@
  * </p>
  */
 public class FileUtils {
+    private static final String NO_SPECIFIED_LOCALDATE = "No specified 
localDate";

Review comment:
       No need for these, just use the parameter name as the message to one of:
   
   - java.util.Objects.requireNonNull(T, String)
   - java.util.Objects.requireNonNull(T, Supplier<String>)
   
   

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1690,6 +1810,119 @@ public static boolean isFileOlder(final File file, 
final long timeMillis) {
         return file.lastModified() < timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is older than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * before the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */
+    public static boolean isFileOlder(final File file, final Instant instant) {
+        if (instant == null) {

Review comment:
       Null checks should use one of:
   
   - java.util.Objects.requireNonNull(T, String)
   - java.util.Objects.requireNonNull(T, Supplier<String>)

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1624,6 +1631,119 @@ public static boolean isFileNewer(final File file, 
final long timeMillis) {
         return file.lastModified() > timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final Instant instant) {
+        if (instant == null) {
+            throw new IllegalArgumentException("No specified instant");
+        }
+        return isFileNewer(file, instant.toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>ZonedDateTime</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param zonedDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>ZonedDateTime</code>.
+     * @throws IllegalArgumentException if the file or zoned date time is 
{@code null}
+     */
+    public static boolean isFileNewer(final File file, final ZonedDateTime 
zonedDateTime) {
+        if (zonedDateTime == null) {
+            throw new IllegalArgumentException("No specified zonedDateTime");
+        }
+        return isFileNewer(file, zonedDateTime.toInstant());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>LocalDateTime</code> at the system-default time zone.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param localDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>LocalDateTime</code> at the system-default time 
zone.
+     * @throws IllegalArgumentException if the file or local date time is 
{@code null}
+     */
+    public static boolean isFileNewer(final File file, final LocalDateTime 
localDateTime) {
+        return isFileNewer(file, localDateTime, ZoneId.systemDefault());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>LocalDateTime</code> at the specified <code>ZoneId</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param localDateTime the date reference, must not be {@code null}
+     * @param zoneId        the time zone, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>LocalDateTime</code> at the given 
<code>ZoneId</code>.
+     * @throws IllegalArgumentException if the file, local date time or zone 
ID is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final LocalDateTime 
localDateTime, final ZoneId zoneId) {
+        if (localDateTime == null) {
+            throw new IllegalArgumentException("No specified localDateTime");
+        }
+        if (zoneId == null) {
+            throw new IllegalArgumentException(NO_SPECIFIED_ZONEID);
+        }
+        return isFileNewer(file, localDateTime.atZone(zoneId));
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>LocalDate</code> at the system-default time zone.
+     *
+     * @param file      the <code>File</code> of which the modification date
+     *                  must be compared, must not be {@code null}
+     * @param localDate the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>LocalDate</code> at the system-default time zone.
+     * @throws IllegalArgumentException if the file or local date is {@code 
null}
+     */
+    public static boolean isFileNewer(final File file, final LocalDate 
localDate) {
+        if (localDate == null) {
+            throw new IllegalArgumentException(NO_SPECIFIED_LOCALDATE);
+        }
+        return isFileNewer(file, localDate.atStartOfDay());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>LocalDate</code> at the specified <code>ZoneId</code>.

Review comment:
       Use `{@code Foo}` instead of `<code>Foo</code>` for these kinds of 
simple styles.

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1624,6 +1631,119 @@ public static boolean isFileNewer(final File file, 
final long timeMillis) {
         return file.lastModified() > timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final Instant instant) {
+        if (instant == null) {
+            throw new IllegalArgumentException("No specified instant");
+        }
+        return isFileNewer(file, instant.toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>ZonedDateTime</code>.
+     *
+     * @param file          the <code>File</code> of which the modification 
date
+     *                      must be compared, must not be {@code null}
+     * @param zonedDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>ZonedDateTime</code>.
+     * @throws IllegalArgumentException if the file or zoned date time is 
{@code null}
+     */
+    public static boolean isFileNewer(final File file, final ZonedDateTime 
zonedDateTime) {

Review comment:
       Why is this API typed to a `ZonedDateTime` instead of 
`ChronoZonedDateTime`?




----------------------------------------------------------------
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.

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


Reply via email to