Package dev.orne.test.rnd.generators
Class FileGenerator
- All Implemented Interfaces:
Generator,TypedGenerator<File>
@API(status=STABLE,
since="0.1")
@Priority(-1000)
public class FileGenerator
extends AbstractTypedGenerator<File>
Generator of
File values.- Since:
- 0.1
- Version:
- 1.0, 2022-11
- Author:
- (w) Iker Hernaez
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property for temporary files directory path.static final StringSystem property for user home directory path.static final StringSystem property for working directory path.Fields inherited from class dev.orne.test.rnd.AbstractGenerator
DEFAULT_NULL_PROBABILITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull FileReturns the default value of the supported type.static @NotNull StringGenerate a random path.static @NotNull StringGenerate a random path segment.@NotNull FileReturns a random value of the supported type.protected static @NotNull StringremoveLastSeparator(@NotNull String path) Removes the last file path separator from the path if exists.static @NotNull FiletmpDir()Returns the default temporary file directory.static @NotNull StringtmpPath()Returns the default temporary file directory path.static @NotNull FileuserDir()Returns the current user's home directory.static @NotNull StringuserPath()Returns the current user's home directory path.static @NotNull FileReturns the current working directory.static @NotNull StringReturns the current working directory path.Methods inherited from class dev.orne.test.rnd.AbstractTypedGenerator
defaultValue, equals, getValueType, hashCode, nullableDefaultValue, nullableRandomValue, randomValue, supportsMethods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, getNullProbability, nullableDefaultValue, nullableRandomValue, randomNull, setNullProbability, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.orne.test.rnd.Generator
asParameterizable, getPriority, nullableDefaultValue, nullableRandomValue
-
Field Details
-
WORKING_DIR_PROP
System property for working directory path.- See Also:
-
USER_DIR_PROP
System property for user home directory path.- See Also:
-
TMP_DIR_PROP
System property for temporary files directory path.- See Also:
-
-
Constructor Details
-
FileGenerator
public FileGenerator()Creates a new instance.
-
-
Method Details
-
defaultValue
Returns the default value of the supported type.- Returns:
- The default value.
-
randomValue
Returns a random value of the supported type.- Returns:
- A random value.
-
workingDir
Returns the current working directory.- Returns:
- The current working directory
-
workingPath
Returns the current working directory path.- Returns:
- The current working directory path
-
userDir
Returns the current user's home directory.- Returns:
- The current user's home directory
-
userPath
Returns the current user's home directory path.- Returns:
- The current user's home directory path
-
tmpDir
Returns the default temporary file directory.- Returns:
- The default temporary file directory
-
tmpPath
Returns the default temporary file directory path.- Returns:
- The default temporary file directory path
-
randomPath
Generate a random path.- Returns:
- The generated random path
-
randomPathSegment
Generate a random path segment.- Returns:
- The generated random path
-
removeLastSeparator
Removes the last file path separator from the path if exists.In some environments some paths end with separator while other paths don't. This methods removes de incoherence.
- Parameters:
path- The path- Returns:
- The path without trailing separator
-