Class Fileset

All Implemented Interfaces:
Serializable, Iterable<File>, Mutable

public final class Fileset extends Object implements Mutable, Iterable<File>
A reference to a set of existing files
See Also:
  • Constructor Details

    • Fileset

      public Fileset(Set<File> files, String base, String pattern)
      Constructs a Fileset
      Parameters:
      files - the set of File objects
      base - the base path of the files, or null
      pattern - the glob pattern for the files, or null
  • Method Details

    • of

      public static Fileset of(File... files)
      Creates a Fileset from an array of File objects
      Parameters:
      files - the File objects
      Returns:
      a new Fileset
    • of

      public static Fileset of(Stream<Path> paths)
      Creates a Fileset from a stream of paths
      Parameters:
      paths - the Path objects
      Returns:
      a new Fileset
    • of

      public static Fileset of(Set<File> files)
      Creates a Fileset from a set of File objects
      Parameters:
      files - the File objects
      Returns:
      a new Fileset
    • find

      public static Fileset find(String selector)
      Creates a Fileset containing all files that match a selection string
      Parameters:
      selector - the selector
      Returns:
      a Fileset with corresponding files, base and pattern
    • find

      public static Fileset find(String base, String pattern)
      Creates a Fileset containing all files that match a selection string
      Parameters:
      base - the base directory to find the files in
      pattern - the selection glob pattern
      Returns:
      a Fileset with the found files and supplied base path and pattern
    • stream

      public Stream<File> stream()
      Streams the files in this set
      Returns:
      the Stream of these files
    • rootPath

      public String rootPath()
      Gets the base path of the files in this set, if there is one
      Returns:
      The base path of this set, or null
    • size

      public int size()
      Gets the number of files in this set
      Returns:
      the number of files
    • pathElements

      public Stream<File> pathElements()
      Gets a stream of contents
      Returns:
      a stream containing either the files or the base directory
    • modified

      public boolean modified()
      Description copied from interface: Mutable
      Checks if the resource has been modified since this reference was created
      Specified by:
      modified in interface Mutable
      Returns:
      true if the resource has been modified
    • file

      public File file(String path)
      Gets a file from this fileset
      Parameters:
      path - the relative path of the file
      Returns:
      a reference to the file
    • iterator

      public Iterator<File> iterator()
      Specified by:
      iterator in interface Iterable<File>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object