Package com.vaadin.flow.server.frontend
Class AbstractFileGeneratorFallibleCommand
java.lang.Object
com.vaadin.flow.server.frontend.AbstractFileGeneratorFallibleCommand
- All Implemented Interfaces:
FallibleCommand
- Direct Known Subclasses:
AbstractTaskClientGenerator
,TaskCopyFrontendFiles
,TaskCopyLocalFrontendFiles
,TaskGenerateReactFiles
,TaskUpdateThemeImport
public abstract class AbstractFileGeneratorFallibleCommand
extends Object
implements FallibleCommand
A base class for commands providing helpers for common file generation
actions.
By extending this class, commands can track generated files for subsequent processes. In addition, it allows to avoid writes on disk of the file already exists and has exactly the same generated content, preventing file system watchers to trigger unnecessary events.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
AcceptsGeneratedFilesSupport
utility allows to track generated files but write them only when the content is changed, preventing filesystem watchers to be triggered when not required.protected void
Marks the give file as generated by the task.protected void
track
(Collection<File> files) Marks the give files as generated by the task.protected boolean
writeIfChanged
(File file, String content) Writes the given content into the given file unless the file already contains that content.protected boolean
writeIfChanged
(File file, List<String> content) Writes the given content into the given file unless the file already contains that content.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.server.frontend.FallibleCommand
execute
-
Constructor Details
-
AbstractFileGeneratorFallibleCommand
public AbstractFileGeneratorFallibleCommand()
-
-
Method Details
-
setGeneratedFileSupport
Description copied from interface:FallibleCommand
AcceptsGeneratedFilesSupport
utility allows to track generated files but write them only when the content is changed, preventing filesystem watchers to be triggered when not required.- Specified by:
setGeneratedFileSupport
in interfaceFallibleCommand
- Parameters:
support
- the generated file support utility to use.
-
writeIfChanged
Writes the given content into the given file unless the file already contains that content.- Parameters:
file
- the file to write tocontent
- the lines to write- Returns:
- true if the content was written to the file, false otherwise
- Throws:
IOException
- if something went wrong
-
writeIfChanged
Writes the given content into the given file unless the file already contains that content.- Parameters:
file
- the file to write tocontent
- the content to write- Returns:
- true if the content was written to the file, false otherwise
- Throws:
IOException
- if something went wrong
-
track
Marks the give file as generated by the task.- Parameters:
file
- the file to be marked as generated.
-
track
Marks the give files as generated by the task.- Parameters:
files
- the collection of files to be marked as generated.
-