code: public static UpdateMonitor getMonitor(File monitoredFile, MonitorType type, String filter) {
  
          if (monitoredFile == null)
              throw new NullPointerException("MonitoredFile must be non-null");
          if (type == null)
              throw new NullPointerException("MonitorType must be non-null");
  
          switch (type) {
              case DIRECTORY:
              case DIRECTORY_RECURSE:
              case DIRECTORY_SELF:
              case DIRECTORY_RECURSE_SELF:
                  return new DirectoryUpdateMonitor(monitoredFile, type, filter);
              case FILE:
                  return new FileUpdateMonitor(monitoredFile);
              default:
                  throw new IllegalArgumentException("Unknown monitor type: " + type);
          }
      }
docs: Obtain an instance of an update monitor that uses the specified cache location, and
  monitors the specified resource with the specified properties. Caller must call {@link #init()} on
  this monitor before the first scheduled scan.
  
  @param monitoredFile
  The name of the resource to monitor (file or directory, may or may not exist)
  @param filter A regex filter limiting the types of resources that will be monitored.
  Only applicable if the primary monitored file is a directory
  @param recurse
  If true, all resources in all subdirectories will be monitored
  
  @return an instance of the UpdateMonitor appropriate for the monitored resource (e.g. File, Directory, or non-existant)