public class Validators
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
protected static class |
Validators.Printer |
| Modifier and Type | Field | Description |
|---|---|---|
static cdc.util.debug.Printable |
PRINTER |
| Modifier and Type | Method | Description |
|---|---|---|
static java.util.Set<java.lang.String> |
getNames() |
|
static Validator<? super java.lang.String> |
getStringValidator(java.lang.String name) |
|
static Validator<? super java.lang.String> |
getStringValidator(java.lang.String name,
cdc.util.lang.FailureReaction reaction) |
|
static <T> Validator<? super T> |
getValidator(java.lang.Class<T> valueClass,
java.lang.String name) |
Returns the validator that has a name and a value type.
|
static <T> Validator<? super T> |
getValidator(java.lang.Class<T> valueClass,
java.lang.String name,
cdc.util.lang.FailureReaction reaction) |
Returns the validator that has a name and a value type.
|
static Validator<?> |
getValidator(java.lang.String name) |
Returns the validator that has a name.
|
static Validator<?> |
getValidator(java.lang.String name,
cdc.util.lang.FailureReaction reaction) |
Returns the validator that has a name.
|
static boolean |
hasValidator(java.lang.String name) |
Returns
true if a validator with a name exists. |
static void |
register(Validator<?> validator,
java.lang.String name) |
Register a validator with a name.
|
static <T> java.util.List<ValidationRecord> |
validate(java.lang.Class<T> valueClass,
java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
T value,
java.lang.String valueName) |
Validates a value with a validator and returns a list of validation records.
|
static <T> void |
validate(java.lang.Class<T> valueClass,
java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
T value,
java.lang.String valueName,
ValidationHandler handler) |
Validates a value with a validator.
|
static <T> void |
validate(java.lang.Class<T> valueClass,
java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
T value,
java.lang.String valueName,
java.util.List<ValidationRecord> records) |
Validates a value with a validator and fills a list of validation records.
|
static void |
validateRaw(java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
java.lang.Object value,
java.lang.String valueName,
ValidationHandler handler) |
Validates a raw value with a validator.
|
static void |
validateRaw(java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
java.lang.Object value,
java.lang.String valueName,
java.util.List<ValidationRecord> records) |
Validates a raw value with a validator and fills a list of validation records.
|
static java.util.List<ValidationRecord> |
validatRaw(java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
java.lang.Object value,
java.lang.String valueName) |
Validates a raw value with a validator and returns a list of validation records.
|
public static void register(Validator<?> validator, java.lang.String name)
validator - The validator.name - The name.java.lang.IllegalArgumentException - When validator or name is null,
or when a validator with that name is already registered.public static java.util.Set<java.lang.String> getNames()
public static boolean hasValidator(java.lang.String name)
true if a validator with a name exists.name - The name.true if a validator named name exists.public static Validator<?> getValidator(java.lang.String name, cdc.util.lang.FailureReaction reaction)
name - The name.reaction - The reaction to adopt if no matching validator is found.name or null or an exception, depending on reaction.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.public static Validator<?> getValidator(java.lang.String name)
name - The name.name.cdc.util.lang.NotFoundException - When no validator is found.public static <T> Validator<? super T> getValidator(java.lang.Class<T> valueClass, java.lang.String name, cdc.util.lang.FailureReaction reaction)
T - The validator value type.valueClass - The validator value class.name - The name.reaction - The reaction to adopt if no matching validator is found.name or null or an exception, depending on reaction.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.IllegalArgumentException - When a validator is found but its value type does not match valueClass.public static <T> Validator<? super T> getValidator(java.lang.Class<T> valueClass, java.lang.String name)
T - The validator value type.valueClass - The validator value class.name - The name.name or null or an exception.cdc.util.lang.NotFoundException - When no validator is found.java.lang.IllegalArgumentException - When a validator is found but its value type does not match valueClass.public static Validator<? super java.lang.String> getStringValidator(java.lang.String name, cdc.util.lang.FailureReaction reaction)
public static Validator<? super java.lang.String> getStringValidator(java.lang.String name)
public static <T> void validate(java.lang.Class<T> valueClass,
java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
T value,
java.lang.String valueName,
ValidationHandler handler)
T - The value type.valueClass - The value class.validatorName - The validator name.reaction - The reaction to adopt if no matching validator is found.value - The value.valueName - The name that must be given to value in messages.handler - The validation messages handler.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.IllegalArgumentException - When a validator is found but its value type does not match valueClass.public static <T> void validate(java.lang.Class<T> valueClass,
java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
T value,
java.lang.String valueName,
java.util.List<ValidationRecord> records)
T - The value type.valueClass - The value class.validatorName - The validator name.reaction - The reaction to adopt if no matching validator is found.value - The value.valueName - The name that must be given to value in messages.records - The list of validation records that must be filled.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.IllegalArgumentException - When a validator is found but its value type does not match valueClass.public static <T> java.util.List<ValidationRecord> validate(java.lang.Class<T> valueClass, java.lang.String validatorName, cdc.util.lang.FailureReaction reaction, T value, java.lang.String valueName)
T - The value type.valueClass - The value class.validatorName - The validator name.reaction - The reaction to adopt if no matching validator is found.value - The value.valueName - The name that must be given to value in messages.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.IllegalArgumentException - When a validator is found but its value type does not match valueClass.public static void validateRaw(java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
java.lang.Object value,
java.lang.String valueName,
ValidationHandler handler)
validatorName - The validator name.reaction - The reaction to adopt if no matching validator is found.value - The value.valueName - The name that must be given to value in messages.handler - The validation messages handler.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.ClassCastException - If value is not null and cannot be assigned to value type of the found validator.public static void validateRaw(java.lang.String validatorName,
cdc.util.lang.FailureReaction reaction,
java.lang.Object value,
java.lang.String valueName,
java.util.List<ValidationRecord> records)
validatorName - The validator name.reaction - The reaction to adopt if no matching validator is found.value - The value.valueName - The name that must be given to value in messages.records - The list of validation records that must be filled.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.ClassCastException - If value is not null and cannot be assigned to value type of the found validator.public static java.util.List<ValidationRecord> validatRaw(java.lang.String validatorName, cdc.util.lang.FailureReaction reaction, java.lang.Object value, java.lang.String valueName)
validatorName - The validator name.reaction - The reaction to adopt if no matching validator is found.value - The value.valueName - The name that must be given to value in messages.cdc.util.lang.NotFoundException - When no validator is found and reaction is FailureReaction.FAIL.java.lang.IllegalArgumentException - When a validator is found but its value type does not match valueClass.Copyright © 2019. All rights reserved.