Top Description Constructors Methods
org.hibernate.validator.internal.util

public final Class ModUtil

extends Object
Class Inheritance
Imports
java.util.List

Helper class for modulo 10/11.
Author
Hardy Ferentschik

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

the result of the mod10 checksum calculation
calculateLuhnMod10Check
(final List<Integer>
The digits over which to calculate the checksum
digits
)

Calculate Luhn Modulo 10 checksum (Luhn algorithm implementation)

public static int

Returns:

the result of the mod10 checksum calculation
calculateMod10Check
(final List<Integer>
The digits over which to calculate the checksum
digits
,
int
Multiplier used for the odd digits in the algorithm
multiplier
,
int
Multiplier used for the even digits in the algorithm
weight
)

Calculate Generic Modulo 10 checksum

public static int

Returns:

the result of the mod11 checksum calculation
calculateMod11Check
(final List<Integer>
the digits for which to calculate the checksum
digits
,
final int
the threshold for the Mod11 algorithm multiplier growth
threshold
)

Calculate Modulo 11 checksum

public static int

Returns:

the result of the mod11 checksum calculation
calculateMod11Check
(final List<Integer>
the digits for which to calculate the checksum
digits
)

Calculate Modulo 11 checksum assuming that the threshold is Integer.MAX_VALUE

public static int

Returns:

the result of mod checksum calculation
calculateModXCheckWithWeights
(final List<Integer>
the digits for which to calculate the checksum
digits
,
int
modulo parameter to be used
moduloParam
,
final int threshold, int...
weights for the sum.
weights
)

Calculate Modulo moduloParam checksum with given weights.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ModUtilback to summary
private ModUtil()

Method Detail

calculateLuhnMod10Checkback to summary
public static int calculateLuhnMod10Check(final List<Integer> digits)

Calculate Luhn Modulo 10 checksum (Luhn algorithm implementation)

Parameters
digits:List<Integer>

The digits over which to calculate the checksum

Returns:int

the result of the mod10 checksum calculation

calculateMod10Checkback to summary
public static int calculateMod10Check(final List<Integer> digits, int multiplier, int weight)

Calculate Generic Modulo 10 checksum

Parameters
digits:List<Integer>

The digits over which to calculate the checksum

multiplier:int

Multiplier used for the odd digits in the algorithm

weight:int

Multiplier used for the even digits in the algorithm

Returns:int

the result of the mod10 checksum calculation

calculateMod11Checkback to summary
public static int calculateMod11Check(final List<Integer> digits, final int threshold)

Calculate Modulo 11 checksum

Parameters
digits:List<Integer>

the digits for which to calculate the checksum

threshold:int

the threshold for the Mod11 algorithm multiplier growth

Returns:int

the result of the mod11 checksum calculation

calculateMod11Checkback to summary
public static int calculateMod11Check(final List<Integer> digits)

Calculate Modulo 11 checksum assuming that the threshold is Integer.MAX_VALUE

Parameters
digits:List<Integer>

the digits for which to calculate the checksum

Returns:int

the result of the mod11 checksum calculation

calculateModXCheckWithWeightsback to summary
public static int calculateModXCheckWithWeights(final List<Integer> digits, int moduloParam, final int threshold, int... weights)

Calculate Modulo moduloParam checksum with given weights. If no weights are provided then weights similar to Modulo 11 checksum will be used. In case when there will be not enough weights provided the ones provided will be used in a looped manner.

Parameters
digits:List<Integer>

the digits for which to calculate the checksum

moduloParam:int

modulo parameter to be used

weights:int[]

weights for the sum.

Returns:int

the result of mod checksum calculation