Package org.instancio.generator.specs
Interface Mod11Spec
- All Superinterfaces:
GeneratorSpec<String>,Mod11GeneratorSpec,NullableGeneratorSpec<String>,ValueSpec<String>
A spec for generating numbers that pass the Mod11 checksum algorithm.
- 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 thatnullvalue 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) Thecharthat represents the check digit when the Mod11 checksum equals10(default value is'X').treatCheck11As(char treatCheck11As) Thecharthat represents the check digit when the Mod11 checksum equals11(default value is'0').
-
Method Details
-
length
Description copied from interface:Mod11GeneratorSpecLength of the number to generate (default value is16).- Specified by:
lengthin interfaceMod11GeneratorSpec- Parameters:
length- of the number to generate- Returns:
- spec builder
-
threshold
Description copied from interface:Mod11GeneratorSpecThe threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely (default value isInteger.MAX_VALUE).- Specified by:
thresholdin interfaceMod11GeneratorSpec- Parameters:
threshold- for the multiplier growth- Returns:
- spec builder
-
startIndex
Description copied from interface:Mod11GeneratorSpecThe start index for calculating the checksum (default value is0).- Specified by:
startIndexin interfaceMod11GeneratorSpec- Parameters:
startIndex- for calculating the checksum (inclusive)- Returns:
- spec builder
-
endIndex
Description copied from interface:Mod11GeneratorSpecThe end index for calculating the checksum.- Specified by:
endIndexin interfaceMod11GeneratorSpec- Parameters:
endIndex- for calculating the checksum (inclusive)- Returns:
- spec builder
-
checkDigitIndex
Description copied from interface:Mod11GeneratorSpecThe 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 interfaceMod11GeneratorSpec- Parameters:
checkDigitIndex- index of the check digit- Returns:
- spec builder
-
treatCheck10As
Description copied from interface:Mod11GeneratorSpecThecharthat represents the check digit when the Mod11 checksum equals10(default value is'X').- Specified by:
treatCheck10Asin interfaceMod11GeneratorSpec- Parameters:
treatCheck10As- check digit character to use when the checksum is10- Returns:
- spec builder
-
treatCheck11As
Description copied from interface:Mod11GeneratorSpecThecharthat represents the check digit when the Mod11 checksum equals11(default value is'0').- Specified by:
treatCheck11Asin interfaceMod11GeneratorSpec- Parameters:
treatCheck11As- check digit character to use when the checksum is11- Returns:
- spec builder
-
leftToRight
Mod11Spec leftToRight()Description copied from interface:Mod11GeneratorSpecSpecifies 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
- Specified by:
leftToRightin interfaceMod11GeneratorSpec- Returns:
- spec builder
-
nullable
Mod11Spec nullable()Description copied from interface:Mod11GeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceMod11GeneratorSpec- Specified by:
nullablein interfaceNullableGeneratorSpec<String>- Specified by:
nullablein interfaceValueSpec<String>- Returns:
- spec builder
-