Interface FileTree<T extends FileResource>

Type Parameters:
T - the contained type
All Superinterfaces:
Resource, Resources<T>
All Known Subinterfaces:
ClassTree, JavaResourceTree
All Known Implementing Classes:
DefaultClassTree, DefaultFileTree, DefaultJavaResourceTree

public interface FileTree<T extends FileResource> extends Resources<T>

The representation of a file tree. A file tree is a collection of FileResources that are contained in a directory hierarchy with a common root.

Implementations of this interface must provide a ResourceFactory that supports the invocation of ResourceFactory.create(ResourceType, Project, Object...) with arguments

  • Project the project
  • Path the root directory
  • String[] an array of ant-style path patterns

Implementations of this interface must ensure that the content of the file tree is not evaluated before a terminal operation is performed on the Stream returned by entries(). The delayed evaluation includes resolving a relative path for root against the project's directory.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes all files in this file tree and directories that are empty after deletion of the files including the root directory.
    Re-scans the file tree for changes.
    Returns the paths of the files in this file tree relative to its root.
    exclude(String pattern)
    Add a ant-style path pattern to exclude from the tree.
    static <T extends FileResource>
    FileTree<T>
    of(Project project, Path directory, Class<T> type, String... patterns)
    Creates a new file tree with elements of the given type from the given project and path.
    of(Project project, Path directory, String... patterns)
    Creates a new general file tree from the given project and path.
    default Path
    Returns the root of the file tree searched for files as an absolute path.
    root(boolean relativize)
    Returns the root of the file tree containing the files.
    Includes directories in the file tree if they match the pattern used when creating the file tree, and are not excluded (i.e. don't match the exclude pattern).

    Methods inherited from interface Resource

    asOfLocalized, isNewerThan, name, type

    Methods inherited from interface Resources

    add, addAll, addAll, asOf, isEmpty, stream
  • Method Details

    • withDirectories

      Includes directories in the file tree if they match the pattern used when creating the file tree, and are not excluded (i.e. don't match the exclude pattern).
      Returns:
      the file tree
    • exclude

      FileTree<T> exclude(String pattern)
      Add a ant-style path pattern to exclude from the tree.
      Parameters:
      pattern - the pattern
      Returns:
      the file tree
    • root

      Path root(boolean relativize)
      Returns the root of the file tree containing the files.
      Parameters:
      relativize - whether to return a path relative to the project's directory
      Returns:
      the path
    • root

      default Path root()
      Returns the root of the file tree searched for files as an absolute path.
      Returns:
      the path
    • entries

      Returns the paths of the files in this file tree relative to its root.
      Returns:
      the stream
    • clear

      Re-scans the file tree for changes.
      Specified by:
      clear in interface Resources<T extends FileResource>
      Returns:
      the file tree
    • cleanup

      void cleanup()
      Deletes all files in this file tree and directories that are empty after deletion of the files including the root directory.
      Specified by:
      cleanup in interface Resource
    • of

      static FileTree<FileResource> of(Project project, Path directory, String... patterns)
      Creates a new general file tree from the given project and path.
      Parameters:
      project - the project
      directory - the root of the file tree relative to the project's directory (or an absolute path)
      patterns - the patterns
      Returns:
      the file tree
    • of

      static <T extends FileResource> FileTree<T> of(Project project, Path directory, Class<T> type, String... patterns)
      Creates a new file tree with elements of the given type from the given project and path.
      Type Parameters:
      T - the generic type
      Parameters:
      project - the project
      directory - the root of the file tree relative to the project's directory (or an absolute path)
      type - the type
      patterns - the patterns
      Returns:
      the file tree