Package org.instancio.generator.specs
Interface PathSpec
- All Superinterfaces:
FilePathSpec<Path>,GeneratorSpec<Path>,PathGeneratorSpec<Path>,ValueSpec<Path>
Spec for generating
Path values.- Since:
- 2.6.0
-
Method Summary
Modifier and TypeMethodDescriptionTerminal method to indicate that the generated path, including parent directories (if any), should be created as a directory in the file system.Terminal method to indicate that the generated path, including parent directories (if any), should be created as a file in the file system.createFile(InputStream content) Terminal method to indicate that the generated path, including parent directories (if any), should be created as a file in the file system and content provided by the input stream written to the file.Generator for the file or directory name.File or directory name prefix.File or directory name suffix.tmp()Generate path withjava.io.tmpdiras the parent directory.
-
Method Details
-
name
Description copied from interface:PathGeneratorSpecGenerator for the file or directory name.Generated path names are formed using the following elements:
[prefix][name][suffix]- Prefix and suffix are optional and are
nullby default. - If no generator is supplied using this method, a random 16-character lowercase name will be generated.
- The concatenation of prefix, name, and suffix must not be blank.
Example:
List<Path> paths = Instancio.ofList(Path.class) .generate(all(Path.class), gen -> gen.nio().path() .prefix("queued_") .name(random -> random.alphanumeric(8)) .suffix(".csv")) .create(); // Sample paths: queued_t5LG4AUw.csv, queued_o0nBWkej.csv, etc- Specified by:
namein interfaceFilePathSpec<Path>- Specified by:
namein interfacePathGeneratorSpec<Path>- Parameters:
nameGenerator- for generating the name- Returns:
- spec builder
- Prefix and suffix are optional and are
-
prefix
Description copied from interface:PathGeneratorSpecFile or directory name prefix. No prefix is added by default.- Specified by:
prefixin interfaceFilePathSpec<Path>- Specified by:
prefixin interfacePathGeneratorSpec<Path>- Parameters:
prefix- to add to the file or directory name- Returns:
- spec builder
-
suffix
Description copied from interface:PathGeneratorSpecFile or directory name suffix. No suffix is added by default.- Specified by:
suffixin interfaceFilePathSpec<Path>- Specified by:
suffixin interfacePathGeneratorSpec<Path>- Parameters:
suffix- to add to the file or directory name- Returns:
- spec builder
-
tmp
PathSpec tmp()Description copied from interface:PathGeneratorSpecGenerate path withjava.io.tmpdiras the parent directory.- Specified by:
tmpin interfaceFilePathSpec<Path>- Specified by:
tmpin interfacePathGeneratorSpec<Path>- Returns:
- spec builder
-
createDirectory
Description copied from interface:PathGeneratorSpecTerminal method to indicate that the generated path, including parent directories (if any), should be created as a directory in the file system.If the directory already exists, then no action will be taken.
- Specified by:
createDirectoryin interfaceFilePathSpec<Path>- Specified by:
createDirectoryin interfacePathGeneratorSpec<Path>- Returns:
- completed spec with no further methods
- See Also:
-
createFile
Description copied from interface:PathGeneratorSpecTerminal method to indicate that the generated path, including parent directories (if any), should be created as a file in the file system.If the file already exists, then no action will be taken.
- Specified by:
createFilein interfaceFilePathSpec<Path>- Specified by:
createFilein interfacePathGeneratorSpec<Path>- Returns:
- completed spec with no further methods
- See Also:
-
createFile
Description copied from interface:PathGeneratorSpecTerminal method to indicate that the generated path, including parent directories (if any), should be created as a file in the file system and content provided by the input stream written to the file.If the file already exists, then no action will be taken.
- Specified by:
createFilein interfaceFilePathSpec<Path>- Specified by:
createFilein interfacePathGeneratorSpec<Path>- Parameters:
content- to write to the file- Returns:
- completed spec with no further methods
- See Also:
-