Package org.instancio.generator.specs
Interface LuhnGeneratorSpec
- All Superinterfaces:
GeneratorSpec<String>
,NullableGeneratorSpec<String>
- All Known Subinterfaces:
LuhnAsGeneratorSpec
,LuhnSpec
A spec for generating numbers that pass the Luhn checksum algorithm.
The following methods:
provided by this interface (as well as their Javadocs)
were copied from the org.hibernate.validator.constraints.LuhnCheck
annotation attributes.
- 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
Length of the number to generate (default value is16
).- Parameters:
length
- of the value to generate- Returns:
- spec builder
- Since:
- 3.1.0
-
length
Generate a number of random length within the specified range.- Parameters:
min
- minimum length (inclusive)max
- maximum length (inclusive)- Returns:
- spec builder
- Since:
- 3.1.0
-
startIndex
The start index for calculating the checksum (default value is0
).- Parameters:
startIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
- Since:
- 3.1.0
-
endIndex
The end index for calculating the checksum.- Parameters:
endIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
- Since:
- 3.1.0
-
checkDigitIndex
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)
.- Parameters:
checkDigitIndex
- index of the check digit- Returns:
- spec builder
- Since:
- 3.1.0
-
nullable
LuhnGeneratorSpec nullable()Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceNullableGeneratorSpec<String>
- Returns:
- spec builder
- Since:
- 3.1.0
-