Example usage for org.apache.commons.validator.routines.checkdigit LuhnCheckDigit LuhnCheckDigit

List of usage examples for org.apache.commons.validator.routines.checkdigit LuhnCheckDigit LuhnCheckDigit

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines.checkdigit LuhnCheckDigit LuhnCheckDigit.

Prototype

public LuhnCheckDigit() 

Source Link

Document

Construct a modulus 10 Luhn Check Digit routine.

Usage

From source file:com.inkubator.common.util.CheckDigitLunh.java

/**
 * Check a series of number is valid or not using lunh algorithm
 *
 * @param number//from   w  w  w . j  a v  a2s.com
 * @return Boolean
 */
public static Boolean isValidNumberByLunh(String number) {
    CheckDigit checkDigit = new LuhnCheckDigit();
    return checkDigit.isValid(number);
}

From source file:com.inkubator.common.util.CheckDigitLunh.java

/**
 * Calculate a number for the check digit
 * @param code//  ww  w  .  j  a v a 2  s  .c om
 * @return String code of check digit
 * @throws org.apache.commons.validator.routines.checkdigit.CheckDigitException
 */
public static String calculate(String code) throws CheckDigitException {
    CheckDigit checkDigit = new LuhnCheckDigit();
    return checkDigit.calculate(code);
}