public static final class FileCache.Inputs.Builder
extends java.lang.Object
FileCache.Inputs.| Constructor and Description |
|---|
Builder(FileCache.Command command)
Creates a
FileCache.Inputs.Builder instance to construct an FileCache.Inputs object. |
| Modifier and Type | Method and Description |
|---|---|
FileCache.Inputs |
build()
Builds an
Inputs instance. |
FileCache.Inputs.Builder |
putBoolean(java.lang.String name,
boolean value)
Adds an input parameter with a Boolean value.
|
FileCache.Inputs.Builder |
putFileHash(java.lang.String name,
java.io.File file)
Adds the hash of a file's contents as an input parameter.
|
FileCache.Inputs.Builder |
putFilePath(java.lang.String name,
java.io.File file)
Adds the path of a file/directory as an input parameter.
|
FileCache.Inputs.Builder |
putFilePathLengthTimestamp(java.lang.String name,
java.io.File file)
Adds a file's path, length and timestamp as input parameters.
|
FileCache.Inputs.Builder |
putLong(java.lang.String name,
long value)
Adds an input parameter with a Long value.
|
FileCache.Inputs.Builder |
putString(java.lang.String name,
java.lang.String value)
Adds an input parameter with a String value.
|
public Builder(@NonNull
FileCache.Command command)
FileCache.Inputs.Builder instance to construct an FileCache.Inputs object.command - the command that identifies a file creator callback function (which
usually corresponds to a Gradle task)public FileCache.Inputs.Builder putFilePath(@NonNull java.lang.String name, @NonNull java.io.File file)
Note that this method is used to indicate that the path of an input file/directory affects the output. Depending on your specific use case, consider adding other properties of the file/directory such as its hash, size, or timestamp as part of the inputs as well.
putFilePathLengthTimestamp(String, File)public FileCache.Inputs.Builder putFileHash(@NonNull java.lang.String name, @NonNull java.io.File file) throws java.io.IOException
Note that this method is used to indicate that the contents of an input file affect the output. Also, by using this method, you are assuming that the hash of a file represents its contents, so beware of accidental hash collisions when two different files with different contents end up having the same hash (although it is unlikely to happen, it is possible). Depending on the specific use case, consider adding other properties of the file such as its path, name, size, or timestamp as part of the inputs as well.
file - the file to be hashed (must not be a directory)java.io.IOExceptionputFilePathLengthTimestamp(String, File)public FileCache.Inputs.Builder putFilePathLengthTimestamp(@NonNull java.lang.String name, @NonNull java.io.File file)
This is much faster than calculating the file hash and approximates it well enough for files that we know are not supposed to change often.
public FileCache.Inputs.Builder putString(@NonNull java.lang.String name, @NonNull java.lang.String value)
public FileCache.Inputs.Builder putBoolean(@NonNull java.lang.String name, boolean value)
public FileCache.Inputs.Builder putLong(@NonNull java.lang.String name, long value)
public FileCache.Inputs build()
Inputs instance.java.lang.IllegalStateException - if the inputs are empty