Package bm.target

Class FileBooleanState

java.lang.Object
bm.target.FileBooleanState
All Implemented Interfaces:
StateProvider, FileState

public class FileBooleanState extends Object implements FileState
Provides the state of a file based on a boolean predicate only, meaning the file can only be in two states: either the predicate returns true or it returns false.
  • Constructor Details

  • Method Details

    • isDirectoryState

      public static FileBooleanState isDirectoryState(Path targetPath)
      Creates a file state which is in state true if the given path exists as a directory. See also FileTarget.directoryCreateTarget(java.nio.file.Path).
      Parameters:
      targetPath - to test
      Returns:
      the state
    • isRegularFileState

      public static FileBooleanState isRegularFileState(Path targetPath)
      Creates a file state which is in state true if the given path exists as a regular file.
      Parameters:
      targetPath - to test
      Returns:
      the state
    • getTargetPath

      public Path getTargetPath()
      Description copied from interface: FileState
      The path of the target this objects represents.
      Specified by:
      getTargetPath in interface FileState
      Returns:
      path of the target
    • getManagedFiles

      public List<Path> getManagedFiles()
      Description copied from interface: FileState
      Provides known files.
      Specified by:
      getManagedFiles in interface FileState
      Returns:
      the list of files in the directory managed by this target or the single file it represents
    • addState

      public void addState(Consumer<byte[]> sink)
      Description copied from interface: StateProvider
      Given a sink for byte[] this method should provide bytes representing a target's value. If the value changes, the bytes provided must change too. But the bytes may also change if the value was not actually changed, though this will result in unnecessary builts of a target.

      This should not mingle in any dependency data.

      As examples consider the full byte content of a file or only its last modified time. The latter changes even if a file is overwritten by itself, but for some cases, i.e. huge files, the time stamp may be preferable.

      Specified by:
      addState in interface StateProvider
      Parameters:
      sink - into which to fill the state representing bytes