Package org.instancio.generator.specs
Interface LuhnSpec
- All Superinterfaces:
GeneratorSpec<String>,LuhnGeneratorSpec,NullableGeneratorSpec<String>,ValueSpec<String>
A spec for generating numbers that pass the Luhn checksum algorithm.
- Since:
- 3.1.0
-
Method Summary
Modifier and TypeMethodDescriptioncheckDigitIndex(int checkDigitIndex) The index of the check digit in the input.endIndex(int endIndex) The end index for calculating the checksum.length(int length) Length of the number to generate (default value is16).length(int min, int max) Generate a number of random length within the specified range.nullable()Indicates thatnullvalue can be generated.startIndex(int startIndex) The start index for calculating the checksum (default value is0).
-
Method Details
-
length
Description copied from interface:LuhnGeneratorSpecLength of the number to generate (default value is16).- Specified by:
lengthin interfaceLuhnGeneratorSpec- Parameters:
length- of the value to generate- Returns:
- spec builder
-
length
Description copied from interface:LuhnGeneratorSpecGenerate a number of random length within the specified range.- Specified by:
lengthin interfaceLuhnGeneratorSpec- Parameters:
min- minimum length (inclusive)max- maximum length (inclusive)- Returns:
- spec builder
-
startIndex
Description copied from interface:LuhnGeneratorSpecThe start index for calculating the checksum (default value is0).- Specified by:
startIndexin interfaceLuhnGeneratorSpec- Parameters:
startIndex- for calculating the checksum (inclusive)- Returns:
- spec builder
-
endIndex
Description copied from interface:LuhnGeneratorSpecThe end index for calculating the checksum.- Specified by:
endIndexin interfaceLuhnGeneratorSpec- Parameters:
endIndex- for calculating the checksum (inclusive)- Returns:
- spec builder
-
checkDigitIndex
Description copied from interface:LuhnGeneratorSpecThe index of the check digit in the input. If not specified, the last digit will be used as the check digit.If set, the digit at the specified index is used. If set the following must hold true:
checkDigitIndex >= 0 && (checkDigitIndex < startIndex || checkDigitIndex >= endIndex).- Specified by:
checkDigitIndexin interfaceLuhnGeneratorSpec- Parameters:
checkDigitIndex- index of the check digit- Returns:
- spec builder
-
nullable
LuhnSpec nullable()Description copied from interface:LuhnGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceLuhnGeneratorSpec- Specified by:
nullablein interfaceNullableGeneratorSpec<String>- Specified by:
nullablein interfaceValueSpec<String>- Returns:
- spec builder
-