Top Description Inners Methods
org.hibernate.validator.constraints

public @Interface Mod11Check

extends Annotation
Annotations
@Documented
@Constraint
validatedBy:
@Target:METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE
@Retention:RUNTIME
@Repeatable:List
Static Imports
java.lang.annotation.ElementType.ANNOTATION_TYPE, .ElementType.CONSTRUCTOR, .ElementType.FIELD, .ElementType.METHOD, .ElementType.PARAMETER, .ElementType.TYPE_USE, .RetentionPolicy.RUNTIME

Modulo 11 check constraint.

Allows to validate that a series of digits passes the Mod11 checksum algorithm. For the most common Mod11 variant the sum calculation is done by multiplying a weight from the rightmost digit (excluding the check digit) to the leftmost. The weight starts with 2 and increases by 1 for each digit. Then the result is used to calculate the check digit using 11 - ( sum % 11 ).

Example: The check digit for 24187 is 3
Sum = 7x2 + 8x3 + 1x4 + 4x5 + 2x6 = 74
11 - (74 % 11) = 11 - 8 = 3, so "24187-3" is a valid character sequence.

The Mod11 calculation can result in 10 or 11; per default 10 is treated as 'X' and 11 as '0', this behavior can be changed using the options treatCheck10As and treatCheck10As.

Some implementations do the sum calculation in the reverse order (left to right); specify the processing direction ProcessingDirection#LEFT_TO_RIGHT in this case.

The supported type is CharSequence. null is considered valid.

Authors
George Gastaldi, Hardy Ferentschik, Victor Rezende dos Santos

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static @interface
Mod11Check.List

Defines several @Mod11Check annotations on the same element.

public static enum

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The index of the check digit in the input. Per default it is assumed that the check digit is the last digit of the specified range. If set, the digit at the specified index is used. If set the following must hold true:
checkDigitIndex > 0 && (checkDigitIndex < startIndex || checkDigitIndex >= endIndex.
checkDigitIndex
()

public int

Returns:

the end index (inclusive) for calculating the checksum. If not specified the whole value is considered
endIndex
()

public Class<?>[]
public boolean

Returns:

Whether non-digit characters in the validated input should be ignored (true) or result in a validation error (false).
ignoreNonDigitCharacters
()

public String
public Class<? extends Payload>[]
public Mod11Check.ProcessingDirection

Returns:

Returns RIGHT_TO_LEFT if the Mod11 checksum must be done from the rightmost to the leftmost digit. 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
If not specified RIGHT_TO_LEFT is assumed, it is the default Mod11 behavior.
processingDirection
()

public int

Returns:

the start index (inclusive) for calculating the checksum. If not specified 0 is assumed.
startIndex
()

public int

Returns:

The threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely
threshold
()

public char

Returns:

The char that represents the check digit when the Mod11 checksum equals 10. If not specified 'X' is assumed.
treatCheck10As
()

public char

Returns:

The char that represents the check digit when the Mod11 checksum equals 11. If not specified '0' is assumed.
treatCheck11As
()

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

checkDigitIndexback to summary
public int checkDigitIndex()
Returns:int

The index of the check digit in the input. Per default it is assumed that the check digit is the last digit of the specified range. If set, the digit at the specified index is used. If set the following must hold true:
checkDigitIndex > 0 && (checkDigitIndex < startIndex || checkDigitIndex >= endIndex.

endIndexback to summary
public int endIndex()
Returns:int

the end index (inclusive) for calculating the checksum. If not specified the whole value is considered

groupsback to summary
public Class<?>[] groups()
ignoreNonDigitCharactersback to summary
public boolean ignoreNonDigitCharacters()
Returns:boolean

Whether non-digit characters in the validated input should be ignored (true) or result in a validation error (false).

messageback to summary
public String message()
payloadback to summary
public Class<? extends Payload>[] payload()
processingDirectionback to summary
public Mod11Check.ProcessingDirection processingDirection()
Returns:Mod11Check.ProcessingDirection

Returns RIGHT_TO_LEFT if the Mod11 checksum must be done from the rightmost to the leftmost digit. 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
If not specified RIGHT_TO_LEFT is assumed, it is the default Mod11 behavior.
startIndexback to summary
public int startIndex()
Returns:int

the start index (inclusive) for calculating the checksum. If not specified 0 is assumed.

thresholdback to summary
public int threshold()
Returns:int

The threshold for the Mod11 algorithm multiplier growth, if no value is specified the multiplier will grow indefinitely

treatCheck10Asback to summary
public char treatCheck10As()
Returns:char

The char that represents the check digit when the Mod11 checksum equals 10. If not specified 'X' is assumed.

treatCheck11Asback to summary
public char treatCheck11As()
Returns:char

The char that represents the check digit when the Mod11 checksum equals 11. If not specified '0' is assumed.

org.hibernate.validator.constraints back to summary

public @Interface Mod11Check.List

extends Annotation
Annotations
@Target:METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE
@Retention:RUNTIME
@Documented

Defines several @Mod11Check annotations on the same element.

Method Summary

Modifier and TypeMethod and Description
public Mod11Check[]
Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public Mod11Check[] value()
org.hibernate.validator.constraints back to summary

public final Enum Mod11Check.ProcessingDirection

extends Enum<Mod11Check.ProcessingDirection>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Mod11Check.ProcessingDirection
public static final Mod11Check.ProcessingDirection

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Mod11Check.ProcessingDirection
public static Mod11Check.ProcessingDirection[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

LEFT_TO_RIGHTback to summary
public static final Mod11Check.ProcessingDirection LEFT_TO_RIGHT
RIGHT_TO_LEFTback to summary
public static final Mod11Check.ProcessingDirection RIGHT_TO_LEFT

Constructor Detail

ProcessingDirectionback to summary
private ProcessingDirection()

Method Detail

valueOfback to summary
public static Mod11Check.ProcessingDirection valueOf(String name)
valuesback to summary
public static Mod11Check.ProcessingDirection[] values()