+ Added directory monitor and Monitored File

This commit is contained in:
Matthew Cech
2019-04-22 00:07:41 -07:00
parent 8d6d7b9567
commit dd7bd44533
2 changed files with 195 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package dataStructures;
import java.nio.file.Path;
public class MonitoredFile implements Comparable<Object>
{
public final Path path;
public final Long lastModified;
public MonitoredFile(Path path, Long lastModified)
{
this.path = path;
this.lastModified = lastModified;
}
// Override equals operator - used for .contains(...) on list items
@Override
public boolean equals(Object other)
{
if(this.compareTo(other) == 0)
return true;
return false;
}
@Override
// Comparison
public int compareTo(Object other)
{
int strCmp = path.getFileName().toString().compareTo(((MonitoredFile)other).path.getFileName().toString());
if(strCmp == 0)
return lastModified.compareTo(((MonitoredFile)other).lastModified);
return strCmp;
}
}