Package org.instancio.generator.specs
Interface Mod11GeneratorSpec
- All Superinterfaces:
GeneratorSpec<String>
,NullableGeneratorSpec<String>
- All Known Subinterfaces:
Mod11AsGeneratorSpec
,Mod11Spec
A spec for generating numbers that pass the Mod11 checksum algorithm.
The methods provided by this interface (as well as their Javadocs)
were copied from the org.hibernate.validator.constraints.Mod11Check
annotation attributes.
- Since:
- 2.16.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.Specifies that the Mod11 checksum must be done from the leftmost to the rightmost digit (default behaviour is right to left).length
(int length) Length of the number to generate (default value is16
).nullable()
Indicates thatnull
value can be generated.startIndex
(int startIndex) The start index for calculating the checksum (default value is0
).threshold
(int threshold) The threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely (default value isInteger.MAX_VALUE
).treatCheck10As
(char treatCheck10As) Thechar
that represents the check digit when the Mod11 checksum equals10
(default value is'X'
).treatCheck11As
(char treatCheck11As) Thechar
that represents the check digit when the Mod11 checksum equals11
(default value is'0'
).
-
Method Details
-
length
Length of the number to generate (default value is16
).- Parameters:
length
- of the number to generate- Returns:
- spec builder
- Since:
- 2.16.0
-
threshold
The threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely (default value isInteger.MAX_VALUE
).- Parameters:
threshold
- for the multiplier growth- Returns:
- spec builder
- Since:
- 2.16.0
-
startIndex
The start index for calculating the checksum (default value is0
).- Parameters:
startIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
- Since:
- 2.16.0
-
endIndex
The end index for calculating the checksum.- Parameters:
endIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
- Since:
- 2.16.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:
- 2.16.0
-
treatCheck10As
Thechar
that represents the check digit when the Mod11 checksum equals10
(default value is'X'
).- Parameters:
treatCheck10As
- check digit character to use when the checksum is10
- Returns:
- spec builder
- Since:
- 2.16.0
-
treatCheck11As
Thechar
that represents the check digit when the Mod11 checksum equals11
(default value is'0'
).- Parameters:
treatCheck11As
- check digit character to use when the checksum is11
- Returns:
- spec builder
- Since:
- 2.16.0
-
leftToRight
Mod11GeneratorSpec leftToRight()Specifies that the Mod11 checksum must be done from the leftmost to the rightmost digit (default behaviour is right to left).e.g. Code 12345-?:
- Right to left: the sum (5*2 + 4*3 + 3*4 + 2*5 + 1*6) with check digit 5
- Left to right: the sum (1*2 + 2*3 + 3*4 + 4*5 + 5*6) with check digit 7
- Returns:
- spec builder
- Since:
- 2.16.0
-
nullable
Mod11GeneratorSpec nullable()Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceNullableGeneratorSpec<String>
- Returns:
- spec builder
- Since:
- 2.16.0
-