com.vaadin.flow.server.frontend.

Class GeneratedFilesSupport

java.lang.Object
com.vaadin.flow.server.frontend.GeneratedFilesSupport
public final class GeneratedFilesSupport extends Object

A helper for tasks to handle generated files.

Allow to write file on disk only if the content has not changed. Generated files are tracked and can be fetched by post-processing tasks.

For internal use only. May be renamed or removed in a future release.

  • Constructor Details

    • GeneratedFilesSupport

      public GeneratedFilesSupport()
  • Method Details

    • writeIfChanged

      public boolean writeIfChanged(File file, List<String> content) throws IOException

      Writes the given content into the given file unless the file already contains that content.

      Parameters:

      file - the file to write to

      content - the lines to write

      Returns:

      true if the content was written to the file, false otherwise

      Throws:

      IOException - if something went wrong

    • writeIfChanged

      public boolean writeIfChanged(Path file, List<String> content) throws IOException

      Writes the given content into the given file unless the file already contains that content.

      Parameters:

      file - the file to write to

      content - the lines to write

      Returns:

      true if the content was written to the file, false otherwise

      Throws:

      IOException - if something went wrong

    • writeIfChanged

      public boolean writeIfChanged(File file, String content) throws IOException

      Writes the given content into the given file unless the file already contains that content.

      Parameters:

      file - the file to write to

      content - the content to write

      Returns:

      true if the content was written to the file, false otherwise

      Throws:

      IOException - if something went wrong

    • writeIfChanged

      public boolean writeIfChanged(Path file, String content) throws IOException

      Writes the given content into the given file unless the file already contains that content.

      Parameters:

      file - the file to write to

      content - the content to write

      Returns:

      true if the content was written to the file, false otherwise

      Throws:

      IOException - if something went wrong

    • track

      public void track(File file)

      Marks the give file as generated by the task.

      Parameters:

      file - the file to be marked as generated.

    • track

      public void track(Path file)

      Marks the give file as generated by the task.

      Parameters:

      file - the file to be marked as generated.

    • getFiles

      public Set<Path> getFiles()

      Gets paths of all generated files, whether they have been written to disk or not.

      Returns:

      paths of files generated under the given root folder, never null.

    • getFiles

      public Set<Path> getFiles(Path root)

      Gets paths of files generated under the given root folder.

      Parameters:

      root - root folder to get generated files.

      Returns:

      paths of files generated under the given root folder, never null.