Top Description Fields Constructors Methods
org.hibernate.validator.internal.constraintvalidators.hv

public Class UUIDValidator

extends Object
implements ConstraintValidator<UUID, CharSequence>
Class Inheritance
All Implemented Interfaces
jakarta.validation.ConstraintValidator
Imports
java.util.Arrays, org.hibernate.validator.constraints.UUID, org.hibernate.validator.internal.util.Contracts, jakarta.validation.ConstraintValidator, .ConstraintValidatorContext

Checks that the annotated character sequence is a valid UUID.
Author
Daniel Heid

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private static final int[]
private UUID.LetterCase
private int[]
private int[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static int[]
checkAndSortMultiOptionParameter(int[] values, String parameterName, int minimum, int maximum)

private static int
extractVariant(int
The old variant (in case the variant has already been extracted)
variant
,
int
The index of the current value to find the variant to extract
index
,
int
The numeric value at the character position
value
)

Get the 3 bit UUID variant from the current value

private static int
extractVersion(int
The old version (in case the version has already been extracted)
version
,
int
The index of the current value to find the version to extract
index
,
int
The numeric value at the character position
value
)

Get the 4 bit UUID version from the current value

private boolean

Returns:

true if the character is in the specified letter case or letter case is not specified
hasCorrectLetterCase
(char
The letter to be tested
ch
)

Validates the letter case of the given character depending on the letter case parameter

public void
initialize(UUID
annotation instance for a given constraint declaration
constraintAnnotation
)

Overrides default jakarta.validation.ConstraintValidator.initialize.

Initializes the validator in preparation for isValid(Object, ConstraintValidatorContext) calls.
public boolean
isValid(CharSequence
object to validate
value
,
ConstraintValidatorContext
context in which the constraint is evaluated
context
)

Implements jakarta.validation.ConstraintValidator.isValid.

Implements the validation logic.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowEmptyback to summary
private boolean allowEmpty
allowNilback to summary
private boolean allowNil
GROUP_LENGTHSback to summary
private static final int[] GROUP_LENGTHS
letterCaseback to summary
private UUID.LetterCase letterCase
variantback to summary
private int[] variant
versionback to summary
private int[] version

Constructor Detail

UUIDValidatorback to summary
public UUIDValidator()

Method Detail

checkAndSortMultiOptionParameterback to summary
private static int[] checkAndSortMultiOptionParameter(int[] values, String parameterName, int minimum, int maximum)
extractVariantback to summary
private static int extractVariant(int variant, int index, int value)

Get the 3 bit UUID variant from the current value

Parameters
variant:int

The old variant (in case the variant has already been extracted)

index:int

The index of the current value to find the variant to extract

value:int

The numeric value at the character position

extractVersionback to summary
private static int extractVersion(int version, int index, int value)

Get the 4 bit UUID version from the current value

Parameters
version:int

The old version (in case the version has already been extracted)

index:int

The index of the current value to find the version to extract

value:int

The numeric value at the character position

hasCorrectLetterCaseback to summary
private boolean hasCorrectLetterCase(char ch)

Validates the letter case of the given character depending on the letter case parameter

Parameters
ch:char

The letter to be tested

Returns:boolean

true if the character is in the specified letter case or letter case is not specified

initializeback to summary
public void initialize(UUID constraintAnnotation)

Overrides default jakarta.validation.ConstraintValidator.initialize.

Doc from jakarta.validation.ConstraintValidator.initialize.

Initializes the validator in preparation for isValid(Object, ConstraintValidatorContext) calls. The constraint annotation for a given constraint declaration is passed.

This method is guaranteed to be called before any use of this instance for validation.

The default implementation is a no-op.

Parameters
constraintAnnotation:UUID

annotation instance for a given constraint declaration

Annotations
@Override
isValidback to summary
public boolean isValid(CharSequence value, ConstraintValidatorContext context)

Implements jakarta.validation.ConstraintValidator.isValid.

Doc from jakarta.validation.ConstraintValidator.isValid.

Implements the validation logic. The state of value must not be altered.

This method can be accessed concurrently, thread-safety must be ensured by the implementation.

Parameters
value:CharSequence

object to validate

context:ConstraintValidatorContext

context in which the constraint is evaluated

Returns:boolean

false if value does not pass the constraint

Annotations
@Override