Package com.vaadin.v7.data.validator
Class CompositeValidator
- java.lang.Object
-
- com.vaadin.v7.data.validator.CompositeValidator
-
- All Implemented Interfaces:
Validator,Serializable
@Deprecated public class CompositeValidator extends Object implements Validator
Deprecated.As of 8.0, no direct replacement available. SeeBinder.forField(HasValue)and various methods for validation and conversion chaining:withValidator(...),withConverter(...),withNullRepresentation(...)TheCompositeValidatorallows you to chain (compose) many validators to validate one field. The contained validators may be required to all validate the value to validate or it may be enough that one contained validator validates the value. This behavior is controlled by the modesANDandOR.- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompositeValidator.CombinationModeDeprecated.-
Nested classes/interfaces inherited from interface com.vaadin.v7.data.Validator
Validator.EmptyValueException, Validator.InvalidValueException
-
-
Field Summary
Fields Modifier and Type Field Description static CompositeValidator.CombinationModeMODE_ANDDeprecated.As of 7.0, useCompositeValidator.CombinationMode.ANDinsteadstatic CompositeValidator.CombinationModeMODE_ORDeprecated.As of 7.0, useCompositeValidator.CombinationMode.ORinstead
-
Constructor Summary
Constructors Constructor Description CompositeValidator()Deprecated.Construct a composite validator inANDmode without error message.CompositeValidator(CompositeValidator.CombinationMode mode, String errorMessage)Deprecated.Constructs a composite validator in given mode.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddValidator(Validator validator)Deprecated.Adds validator to the interface.StringgetErrorMessage()Deprecated.Gets the error message for the composite validator.CompositeValidator.CombinationModegetMode()Deprecated.Gets the mode of the validator.Collection<Validator>getSubValidators(Class<?> validatorType)Deprecated.Gets sub-validators by class.voidremoveValidator(Validator validator)Deprecated.Removes a validator from the composite.voidsetErrorMessage(String errorMessage)Deprecated.Sets the message to be included in the exception in case the value does not validate.voidsetMode(CompositeValidator.CombinationMode mode)Deprecated.Sets the mode of the validator.voidvalidate(Object value)Deprecated.Validates the given value.
-
-
-
Field Detail
-
MODE_AND
@Deprecated public static final CompositeValidator.CombinationMode MODE_AND
Deprecated.As of 7.0, useCompositeValidator.CombinationMode.ANDinstead
-
MODE_OR
@Deprecated public static final CompositeValidator.CombinationMode MODE_OR
Deprecated.As of 7.0, useCompositeValidator.CombinationMode.ORinstead
-
-
Constructor Detail
-
CompositeValidator
public CompositeValidator()
Deprecated.Construct a composite validator inANDmode without error message.
-
CompositeValidator
public CompositeValidator(CompositeValidator.CombinationMode mode, String errorMessage)
Deprecated.Constructs a composite validator in given mode.- Parameters:
mode-errorMessage-
-
-
Method Detail
-
validate
public void validate(Object value) throws Validator.InvalidValueException
Deprecated.Validates the given value.
The value is valid, if:MODE_AND: All of the sub-validators are validMODE_OR: Any of the sub-validators are valid
If the value is invalid, validation error is thrown. If the error message is set (non-null), it is used. If the error message has not been set, the first error occurred is thrown.
- Specified by:
validatein interfaceValidator- Parameters:
value- the value to check.- Throws:
Validator.InvalidValueException- if the value is not valid.
-
getMode
public final CompositeValidator.CombinationMode getMode()
Deprecated.Gets the mode of the validator.- Returns:
- Operation mode of the validator:
CompositeValidator.CombinationMode.ANDorCompositeValidator.CombinationMode.OR.
-
setMode
public void setMode(CompositeValidator.CombinationMode mode)
Deprecated.Sets the mode of the validator. The valid modes are:- Parameters:
mode- the mode to set.
-
getErrorMessage
public String getErrorMessage()
Deprecated.Gets the error message for the composite validator. If the error message is null, original error messages of the sub-validators are used instead.
-
addValidator
public void addValidator(Validator validator)
Deprecated.Adds validator to the interface.- Parameters:
validator- the Validator object which performs validation checks on this set of data field values.
-
removeValidator
public void removeValidator(Validator validator)
Deprecated.Removes a validator from the composite.- Parameters:
validator- the Validator object which performs validation checks on this set of data field values.
-
getSubValidators
public Collection<Validator> getSubValidators(Class<?> validatorType)
Deprecated.Gets sub-validators by class.If the component contains directly or recursively (it contains another composite containing the validator) validators compatible with given type they are returned. This only applies to
ANDmode composite validators.If the validator is in
ORmode or does not contain any validators of given type null is returned.- Parameters:
validatorType- The type of validators to return- Returns:
- Collection of validators compatible with given type that must apply or null if none found.
-
setErrorMessage
public void setErrorMessage(String errorMessage)
Deprecated.Sets the message to be included in the exception in case the value does not validate. The exception message is typically shown to the end user.- Parameters:
errorMessage- the error message.
-
-