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 thatnullvalue 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 StringtryGenerateNonNull(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, nullableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asString
-
Constructor Details
-
HashGenerator
public HashGenerator() -
HashGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<String>- Returns:
- spec name if defined, or
nullotherwise
-
md5
Description copied from interface:HashGeneratorSpecSpecifies that an MD5 hash should be generated.- Specified by:
md5in interfaceHashAsGeneratorSpec- Specified by:
md5in interfaceHashGeneratorSpec- Specified by:
md5in interfaceHashSpec- Returns:
- spec builder
-
sha1
Description copied from interface:HashGeneratorSpecSpecifies that a SHA-1 hash should be generated.- Specified by:
sha1in interfaceHashAsGeneratorSpec- Specified by:
sha1in interfaceHashGeneratorSpec- Specified by:
sha1in interfaceHashSpec- Returns:
- spec builder
-
sha256
Description copied from interface:HashGeneratorSpecSpecifies that a SHA-256 hash should be generated.- Specified by:
sha256in interfaceHashAsGeneratorSpec- Specified by:
sha256in interfaceHashGeneratorSpec- Specified by:
sha256in interfaceHashSpec- Returns:
- spec builder
-
sha512
Description copied from interface:HashGeneratorSpecSpecifies that a SHA-512 hash should be generated.- Specified by:
sha512in interfaceHashAsGeneratorSpec- Specified by:
sha512in interfaceHashGeneratorSpec- Specified by:
sha512in interfaceHashSpec- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceHashAsGeneratorSpec- Specified by:
nullablein interfaceHashGeneratorSpec- Specified by:
nullablein interfaceHashSpec- Specified by:
nullablein interfaceNullableGeneratorSpec<String>- Specified by:
nullablein interfaceValueSpec<String>- Overrides:
nullablein classAbstractGenerator<String>- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGeneratorMakes the best effort to return a non-null value. However, in certain cases this method will produce anull.- Specified by:
tryGenerateNonNullin classAbstractGenerator<String>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-