Interface Mod11Spec

All Superinterfaces:
GeneratorSpec<String>, Mod11GeneratorSpec, NullableGeneratorSpec<String>, ValueSpec<String>

public interface Mod11Spec extends Mod11GeneratorSpec, ValueSpec<String>
A spec for generating numbers that pass the Mod11 checksum algorithm.
Since:
2.16.0
  • Method Summary

    Modifier and Type
    Method
    Description
    checkDigitIndex(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 is 16).
    Indicates that null value can be generated.
    startIndex(int startIndex)
    The start index for calculating the checksum (default value is 0).
    threshold(int threshold)
    The threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely (default value is Integer.MAX_VALUE).
    treatCheck10As(char treatCheck10As)
    The char that represents the check digit when the Mod11 checksum equals 10 (default value is 'X').
    treatCheck11As(char treatCheck11As)
    The char that represents the check digit when the Mod11 checksum equals 11 (default value is '0').

    Methods inherited from interface org.instancio.generator.ValueSpec

    get, list, map, stream, toModel
  • Method Details

    • length

      Mod11Spec length(int length)
      Description copied from interface: Mod11GeneratorSpec
      Length of the number to generate (default value is 16).
      Specified by:
      length in interface Mod11GeneratorSpec
      Parameters:
      length - of the number to generate
      Returns:
      spec builder
    • threshold

      Mod11Spec threshold(int 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 is Integer.MAX_VALUE).
      Specified by:
      threshold in interface Mod11GeneratorSpec
      Parameters:
      threshold - for the multiplier growth
      Returns:
      spec builder
    • startIndex

      Mod11Spec startIndex(int startIndex)
      Description copied from interface: Mod11GeneratorSpec
      The start index for calculating the checksum (default value is 0).
      Specified by:
      startIndex in interface Mod11GeneratorSpec
      Parameters:
      startIndex - for calculating the checksum (inclusive)
      Returns:
      spec builder
    • endIndex

      Mod11Spec endIndex(int endIndex)
      Description copied from interface: Mod11GeneratorSpec
      The end index for calculating the checksum.
      Specified by:
      endIndex in interface Mod11GeneratorSpec
      Parameters:
      endIndex - for calculating the checksum (inclusive)
      Returns:
      spec builder
    • checkDigitIndex

      Mod11Spec checkDigitIndex(int 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 interface Mod11GeneratorSpec
      Parameters:
      checkDigitIndex - index of the check digit
      Returns:
      spec builder
    • treatCheck10As

      Mod11Spec treatCheck10As(char treatCheck10As)
      Description copied from interface: Mod11GeneratorSpec
      The char that represents the check digit when the Mod11 checksum equals 10 (default value is 'X').
      Specified by:
      treatCheck10As in interface Mod11GeneratorSpec
      Parameters:
      treatCheck10As - check digit character to use when the checksum is 10
      Returns:
      spec builder
    • treatCheck11As

      Mod11Spec treatCheck11As(char treatCheck11As)
      Description copied from interface: Mod11GeneratorSpec
      The char that represents the check digit when the Mod11 checksum equals 11 (default value is '0').
      Specified by:
      treatCheck11As in interface Mod11GeneratorSpec
      Parameters:
      treatCheck11As - check digit character to use when the checksum is 11
      Returns:
      spec builder
    • leftToRight

      Mod11Spec 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 interface Mod11GeneratorSpec
      Returns:
      spec builder
    • nullable

      Mod11Spec nullable()
      Description copied from interface: Mod11GeneratorSpec
      Indicates that null value can be generated.
      Specified by:
      nullable in interface Mod11GeneratorSpec
      Specified by:
      nullable in interface NullableGeneratorSpec<String>
      Specified by:
      nullable in interface ValueSpec<String>
      Returns:
      spec builder