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 thatnull
value can be generated.startIndex
(int startIndex) The start index for calculating the checksum (default value is0
).
-
Method Details
-
length
Description copied from interface:LuhnGeneratorSpec
Length of the number to generate (default value is16
).- Specified by:
length
in interfaceLuhnGeneratorSpec
- Parameters:
length
- of the value to generate- Returns:
- spec builder
-
length
Description copied from interface:LuhnGeneratorSpec
Generate a number of random length within the specified range.- Specified by:
length
in interfaceLuhnGeneratorSpec
- Parameters:
min
- minimum length (inclusive)max
- maximum length (inclusive)- Returns:
- spec builder
-
startIndex
Description copied from interface:LuhnGeneratorSpec
The start index for calculating the checksum (default value is0
).- Specified by:
startIndex
in interfaceLuhnGeneratorSpec
- Parameters:
startIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
-
endIndex
Description copied from interface:LuhnGeneratorSpec
The end index for calculating the checksum.- Specified by:
endIndex
in interfaceLuhnGeneratorSpec
- Parameters:
endIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
-
checkDigitIndex
Description copied from interface:LuhnGeneratorSpec
The 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:
checkDigitIndex
in interfaceLuhnGeneratorSpec
- Parameters:
checkDigitIndex
- index of the check digit- Returns:
- spec builder
-
nullable
LuhnSpec nullable()Description copied from interface:LuhnGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceLuhnGeneratorSpec
- Specified by:
nullable
in interfaceNullableGeneratorSpec<String>
- Specified by:
nullable
in interfaceValueSpec<String>
- Returns:
- spec builder
-