package droplauncher.util;

import adakite.util.AdakiteUtils;
import java.io.IOException;
import java.nio.file.Path;

public class DirectoryMonitor {

  private Path path;
  private Path[] prevFiles;
  private Path[] currFiles;
  private Path[] newFiles;

  private DirectoryMonitor() {}

  public DirectoryMonitor(Path directory) {
    this.path = directory;
    this.prevFiles = new Path[]{};
    this.currFiles = new Path[]{};
    this.newFiles = new Path[]{};
  }

  public Path getPath() {
    return this.path;
  }

  public Path[] getPreviousFiles() {
    return this.prevFiles;
  }

  public Path[] getCurrentFiles() {
    return this.currFiles;
  }

  public Path[] getNewFiles() {
    return this.newFiles;
  }

  public void reset() throws IOException {
    this.prevFiles = AdakiteUtils.getDirectoryContents(this.path);
    this.currFiles = AdakiteUtils.getDirectoryContents(this.path);
    this.newFiles = AdakiteUtils.getDirectoryContents(this.path);
  }



}

@@ -110,16 +110,147 @@
 e.Path;%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0A/**%0A * Class for monitoring a directory structure.%0A */
 %0Apublic 
@@ -306,22 +306,26 @@
 private 
+List%3C
 Path
-%5B%5D
+%3E
  prevFil
@@ -338,22 +338,26 @@
 private 
+List%3C
 Path
-%5B%5D
+%3E
  currFil
@@ -370,22 +370,26 @@
 private 
+List%3C
 Path
-%5B%5D
+%3E
  newFile
@@ -517,32 +517,37 @@
 Files = new 
-Path%5B%5D%7B%7D
+ArrayList%3C%3E()
 ;%0A    this.c
@@ -557,32 +557,37 @@
 Files = new 
-Path%5B%5D%7B%7D
+ArrayList%3C%3E()
 ;%0A    this.n
@@ -604,75 +604,246 @@
 new 
-Path%5B%5D%7B%7D;%0A  %7D%0A%0A  public Path getPath() %7B%0A    return this.path;%0A  %7D%0A
+ArrayList%3C%3E();%0A  %7D%0A%0A  /**%0A   * Returns the path to the currently monitored directory.%0A   */%0A  public Path getPath() %7B%0A    return this.path;%0A  %7D%0A%0A  /**%0A   * Returns the contents of the directory observed at the last %7B@link #reset()%7D.%0A   */
 %0A  p
@@ -844,30 +844,34 @@
 */%0A  public 
+List%3C
 Path
-%5B%5D
+%3E
  getPrevious
@@ -904,32 +904,152 @@
 prevFiles;%0A  %7D%0A%0A
+  /**%0A   * Returns the contents of the directory observed at the last%0A   * %7B@link #reset()%7D or %7B@link #update()%7D.%0A   */%0A
   public Path%5B%5D 
@@ -1037,30 +1037,34 @@
 */%0A  public 
+List%3C
 Path
-%5B%5D
+%3E
  getCurrentF
@@ -1096,32 +1096,152 @@
 currFiles;%0A  %7D%0A%0A
+  /**%0A   * Returns the contents of the directory observed at the last%0A   * %7B@link #reset()%7D or %7B@link #update()%7D.%0A   */%0A
   public Path%5B%5D 
@@ -1237,14 +1237,18 @@
 lic 
+List%3C
 Path
-%5B%5D
+%3E
  get
@@ -1297,70 +1297,265 @@
 %0A%0A  
-public void reset() throws IOException %7B%0A    this.prevFiles = 
+/**%0A   * Resets the new files list and refreshes both previous and current files%0A   * lists.%0A   *%0A   * @throws IOException if an I/O error occurs%0A   */%0A  public void reset() throws IOException %7B%0A    this.newFiles.clear();%0A    this.prevFiles = Arrays.asList(
 Adak
@@ -1586,32 +1586,33 @@
 tents(this.path)
+)
 ;%0A    this.currF
@@ -1622,74 +1622,378 @@
 s = 
-AdakiteUtils.getDirectoryContents(this.path);%0A    this.newFiles = 
+new ArrayList%3C%3E(this.prevFiles);%0A  %7D%0A%0A  /**%0A   * Refreshes the current files list and fills the new files list by comparing%0A   * the previous files list to the current files list.%0A   *%0A   * @see #getNewFiles()%0A   * @throws IOException if an I/O error occurs%0A   */%0A  public void update() throws IOException %7B%0A    this.newFiles.clear();%0A    this.currFiles = Arrays.asList(
 Adak
@@ -2032,19 +2032,214 @@
 is.path)
+)
 ;%0A  
-%7D%0A%0A
+  for (Path currFile : this.currFiles) %7B%0A      if (!this.prevFiles.contains(currFile)) %7B%0A        this.newFiles.add(currFile);%0A      %7D%0A    %7D%0A    this.prevFiles = new ArrayList%3C%3E(this.currFiles);%0A  %7D
 %0A%0A%7D%0A

Add file DirectoryMonitor.java