Package bm.target
Class FileContentState
java.lang.Object
bm.target.FileContentState
- All Implemented Interfaces:
StateProvider,FileState
Provides file or directory states reading either the full content of files or only their last
modified time, depending on the factory method used.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionFileContentState(Path targetPath, FileContentState.ByteSource bytes) Calls the 4 parameter constructor with predicates which always returntrue.FileContentState(Path targetPath, FileContentState.ByteSource bytes, Predicate<Path> includeRelativeFilePath) Calls the 4 parameter constructor with a directory predicate which always returnstrue.FileContentState(Path targetPath, FileContentState.ByteSource bytes, Predicate<Path> includeRelativeFilePath, Predicate<Path> includeRelativeDirPath) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the managed files' state to the given consumer.static FileContentStatefromContent(String targetPath) Creates a file/directory state provider from full file contents.static FileContentStatefromContent(Path targetPath) Creates a file/directory state provider from full file contents.static FileContentStatefromLastModified(String targetPath) Creates a file/directory state provider from a file's last modified time.static FileContentStatefromLastModified(Path targetPath) Creates a file/directory state provider from a file's last modified time.Provides known files.The path of the target this objects represents.withDirPathFilter(Predicate<Path> newIncludeRelativePath) withFilePathFilter(Predicate<Path> newIncludeRelativePath) Creates a newFileStatewith the given filter for relative paths.withPathFilters(PathPredicates predicates) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface bm.target.FileState
getManagedRelative, toFileTarget, toFileTarget
-
Constructor Details
-
FileContentState
Calls the 4 parameter constructor with predicates which always returntrue. -
FileContentState
public FileContentState(Path targetPath, FileContentState.ByteSource bytes, Predicate<Path> includeRelativeFilePath) Calls the 4 parameter constructor with a directory predicate which always returnstrue. -
FileContentState
public FileContentState(Path targetPath, FileContentState.ByteSource bytes, Predicate<Path> includeRelativeFilePath, Predicate<Path> includeRelativeDirPath) Creates an instance.- Parameters:
targetPath- we managebytes- should add the relevant indicative bytes of the file to a digestincludeRelativeFilePath- will be called with each file path relative to thetargetPathand only iftrueis returned, the file is included in the state.includeRelativeDirPath- will be called with each directory path relative to thetargetPath(except the empty path representing the target path itself). Iffalseis returned, the directory is not traversed and no file in it can end up in the state.
-
-
Method Details
-
fromContent
Creates a file/directory state provider from full file contents.- Parameters:
targetPath- file path to the target we maintain, either file or directory
-
fromContent
Creates a file/directory state provider from full file contents.- Parameters:
targetPath- file path to the target we maintain, either file or directory
-
fromLastModified
Creates a file/directory state provider from a file's last modified time.- Parameters:
targetPath- file path to the target we maintain, either file or directory
-
fromLastModified
Creates a file/directory state provider from a file's last modified time.- Parameters:
targetPath- file path to the target we maintain, either file or directory
-
withFilePathFilter
Creates a newFileStatewith the given filter for relative paths.- Parameters:
newIncludeRelativePath- see description forthe constructor- Returns:
- a new instance with the filter provided
-
withDirPathFilter
-
withPathFilters
-
getTargetPath
The path of the target this objects represents.- Specified by:
getTargetPathin interfaceFileState- Returns:
- path of the target
-
getManagedFiles
Provides known files.- Specified by:
getManagedFilesin interfaceFileState- Returns:
- the list of files in the directory managed by this target or the single file it represents
-
addState
Adds the managed files' state to the given consumer.- Specified by:
addStatein interfaceStateProvider- Parameters:
digest- into which to fill the state representing bytes- Throws:
BuildProblemException- as needed
-