Interface LuhnSpec

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

public interface LuhnSpec extends LuhnGeneratorSpec, ValueSpec<String>
A spec for generating numbers that pass the Luhn checksum algorithm.
Since:
3.1.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.
    length(int length)
    Length of the number to generate (default value is 16).
    length(int min, int max)
    Generate a number of random length within the specified range.
    Indicates that null value can be generated.
    startIndex(int startIndex)
    The start index for calculating the checksum (default value is 0).

    Methods inherited from interface org.instancio.generator.ValueSpec

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

    • length

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

      LuhnSpec length(int min, int max)
      Description copied from interface: LuhnGeneratorSpec
      Generate a number of random length within the specified range.
      Specified by:
      length in interface LuhnGeneratorSpec
      Parameters:
      min - minimum length (inclusive)
      max - maximum length (inclusive)
      Returns:
      spec builder
    • startIndex

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

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

      LuhnSpec checkDigitIndex(int checkDigitIndex)
      Description copied from interface: LuhnGeneratorSpec
      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 LuhnGeneratorSpec
      Parameters:
      checkDigitIndex - index of the check digit
      Returns:
      spec builder
    • nullable

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