Package org.instancio.generator.specs
Interface Mod11AsGeneratorSpec
- All Superinterfaces:
AsGeneratorSpec<String>
,GeneratorSpec<String>
,Mod11GeneratorSpec
,NullableGeneratorSpec<String>
A spec for generating numbers that pass the Mod11 checksum algorithm.
This spec supports
AsGeneratorSpec
.- 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'
).Methods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asString
-
Method Details
-
length
Description copied from interface:Mod11GeneratorSpec
Length of the number to generate (default value is16
).- Specified by:
length
in interfaceMod11GeneratorSpec
- Parameters:
length
- of the number to generate- Returns:
- spec builder
-
threshold
Description copied from interface:Mod11GeneratorSpec
The threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely (default value isInteger.MAX_VALUE
).- Specified by:
threshold
in interfaceMod11GeneratorSpec
- Parameters:
threshold
- for the multiplier growth- Returns:
- spec builder
-
startIndex
Description copied from interface:Mod11GeneratorSpec
The start index for calculating the checksum (default value is0
).- Specified by:
startIndex
in interfaceMod11GeneratorSpec
- Parameters:
startIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
-
endIndex
Description copied from interface:Mod11GeneratorSpec
The end index for calculating the checksum.- Specified by:
endIndex
in interfaceMod11GeneratorSpec
- Parameters:
endIndex
- for calculating the checksum (inclusive)- Returns:
- spec builder
-
checkDigitIndex
Description copied from interface:Mod11GeneratorSpec
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 interfaceMod11GeneratorSpec
- Parameters:
checkDigitIndex
- index of the check digit- Returns:
- spec builder
-
treatCheck10As
Description copied from interface:Mod11GeneratorSpec
Thechar
that represents the check digit when the Mod11 checksum equals10
(default value is'X'
).- Specified by:
treatCheck10As
in interfaceMod11GeneratorSpec
- Parameters:
treatCheck10As
- check digit character to use when the checksum is10
- Returns:
- spec builder
-
treatCheck11As
Description copied from interface:Mod11GeneratorSpec
Thechar
that represents the check digit when the Mod11 checksum equals11
(default value is'0'
).- Specified by:
treatCheck11As
in interfaceMod11GeneratorSpec
- Parameters:
treatCheck11As
- check digit character to use when the checksum is11
- Returns:
- spec builder
-
leftToRight
Mod11AsGeneratorSpec leftToRight()Description copied from interface:Mod11GeneratorSpec
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
- Specified by:
leftToRight
in interfaceMod11GeneratorSpec
- Returns:
- spec builder
-
nullable
Mod11AsGeneratorSpec nullable()Description copied from interface:Mod11GeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceMod11GeneratorSpec
- Specified by:
nullable
in interfaceNullableGeneratorSpec<String>
- Returns:
- spec builder
-