Class HashGenerator
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<String>
org.instancio.internal.generator.domain.hash.HashGenerator
- All Implemented Interfaces:
Generator<String>
,GeneratorSpec<String>
,AsGeneratorSpec<String>
,HashAsGeneratorSpec
,HashGeneratorSpec
,HashSpec
,NullableGeneratorSpec<String>
,ValueSpec<String>
public class HashGenerator
extends AbstractGenerator<String>
implements HashSpec, HashAsGeneratorSpec
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.md5()
Specifies that an MD5 hash should be generated.nullable()
Indicates thatnull
value can be generated.sha1()
Specifies that a SHA-1 hash should be generated.sha256()
Specifies that a SHA-256 hash should be generated.sha512()
Specifies that a SHA-512 hash should be generated.protected String
tryGenerateNonNull
(Random random) Makes the best effort to return a non-null value.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
generate, getContext, hints, isNullable, nullable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asString
-
Constructor Details
-
HashGenerator
public HashGenerator() -
HashGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGenerator
Returns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethod
in classAbstractGenerator<String>
- Returns:
- spec name if defined, or
null
otherwise
-
md5
Description copied from interface:HashGeneratorSpec
Specifies that an MD5 hash should be generated.- Specified by:
md5
in interfaceHashAsGeneratorSpec
- Specified by:
md5
in interfaceHashGeneratorSpec
- Specified by:
md5
in interfaceHashSpec
- Returns:
- spec builder
-
sha1
Description copied from interface:HashGeneratorSpec
Specifies that a SHA-1 hash should be generated.- Specified by:
sha1
in interfaceHashAsGeneratorSpec
- Specified by:
sha1
in interfaceHashGeneratorSpec
- Specified by:
sha1
in interfaceHashSpec
- Returns:
- spec builder
-
sha256
Description copied from interface:HashGeneratorSpec
Specifies that a SHA-256 hash should be generated.- Specified by:
sha256
in interfaceHashAsGeneratorSpec
- Specified by:
sha256
in interfaceHashGeneratorSpec
- Specified by:
sha256
in interfaceHashSpec
- Returns:
- spec builder
-
sha512
Description copied from interface:HashGeneratorSpec
Specifies that a SHA-512 hash should be generated.- Specified by:
sha512
in interfaceHashAsGeneratorSpec
- Specified by:
sha512
in interfaceHashGeneratorSpec
- Specified by:
sha512
in interfaceHashSpec
- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceHashAsGeneratorSpec
- Specified by:
nullable
in interfaceHashGeneratorSpec
- Specified by:
nullable
in interfaceHashSpec
- Specified by:
nullable
in interfaceNullableGeneratorSpec<String>
- Specified by:
nullable
in interfaceValueSpec<String>
- Overrides:
nullable
in classAbstractGenerator<String>
- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGenerator
Makes the best effort to return a non-null value. However, in certain cases this method will produce anull
.- Specified by:
tryGenerateNonNull
in classAbstractGenerator<String>
- Parameters:
random
- for generating the value- Returns:
- generated value, either a null or non-null
-