Class AbstractModulo<T>

java.lang.Object
com.github.toolarium.security.checkdigit.AbstractModulo<T>
All Implemented Interfaces:
IModulo<T>
Direct Known Subclasses:
Modulo10, Modulo11

public abstract class AbstractModulo<T> extends Object implements IModulo<T>
Implements the base class of modulo calculation
  • Constructor Details

    • AbstractModulo

      public AbstractModulo()
  • Method Details

    • validate

      public boolean validate(String data)
      Description copied from interface: IModulo
      Validate a number if modulo is valid
      Specified by:
      validate in interface IModulo<T>
      Parameters:
      data - the number to be checked
      Returns:
      true if it is valid; otherwise false
      See Also:
    • calculateSum

      protected abstract long calculateSum(Integer[] digits)
      Calculate the modulo sum
      Parameters:
      digits - the integer digits
      Returns:
      the sum
    • calculateModulo

      protected long calculateModulo(String data)
      Calculate the modulo of the given string .
      Parameters:
      data - the data to parse
      Returns:
      the modulo result
      Throws:
      IllegalArgumentException - In case of an invalid input
    • parseString

      protected Integer[] parseString(String inputData)
      Parse the given string
      Parameters:
      inputData - the data to parse
      Returns:
      the parsed number
      Throws:
      IllegalArgumentException - In case of an invalid input