Package org.dlese.dpc.util
Class FileModDateComparator
java.lang.Object
org.dlese.dpc.util.FileModDateComparator
- All Implemented Interfaces:
Comparator
Compares two Files based on their modification date.
- Version:
- $Id: FileModDateComparator.java,v 1.2 2009/03/20 23:34:00 jweather Exp $
- Author:
- John Weatherley
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSort by newest first.static final intSort by oldest first. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that sorts by newest first.FileModDateComparator(int sortOrder) Constructor that allows setting the sort order by newest or oldest first. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
NEWEST_FIRST
public static final int NEWEST_FIRSTSort by newest first.- See Also:
-
OLDEST_FIRST
public static final int OLDEST_FIRSTSort by oldest first.- See Also:
-
-
Constructor Details
-
FileModDateComparator
public FileModDateComparator(int sortOrder) Constructor that allows setting the sort order by newest or oldest first.- Parameters:
sortOrder- The order for sorting (NEWEST_FIRST or OLDEST_FIRST)- See Also:
-
FileModDateComparator
public FileModDateComparator()Default constructor that sorts by newest first.
-
-
Method Details
-
compare
Compares two Files for sorting by their modification date.Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- Specified by:
comparein interfaceComparator- Parameters:
o1- The first Object.o2- The second Object.- Returns:
- An int indicating sort order.
-