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 String
System property for temporary files directory path.static final String
System property for user home directory path.static final String
System 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 File
Returns the default value of the supported type.static @NotNull String
Generate a random path.static @NotNull String
Generate a random path segment.@NotNull File
Returns a random value of the supported type.protected static @NotNull String
removeLastSeparator
(@NotNull String path) Removes the last file path separator from the path if exists.static @NotNull File
tmpDir()
Returns the default temporary file directory.static @NotNull String
tmpPath()
Returns the default temporary file directory path.static @NotNull File
userDir()
Returns the current user's home directory.static @NotNull String
userPath()
Returns the current user's home directory path.static @NotNull File
Returns the current working directory.static @NotNull String
Returns the current working directory path.Methods inherited from class dev.orne.test.rnd.AbstractTypedGenerator
defaultValue, equals, getValueType, hashCode, nullableDefaultValue, nullableRandomValue, randomValue, supports
Methods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, getNullProbability, nullableDefaultValue, nullableRandomValue, randomNull, setNullProbability, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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
-