V
- is the generic type of the value to validate
.public class ComposedValidator<V> extends AbstractValidator<V> implements ComposedValueValidator<V>
ValueValidator
that is composed out of a set of individual
validators
given at construction
. It will
always invoke all contained validators
when a validation
is performed.Modifier and Type | Field and Description |
---|---|
static String |
CODE |
private AbstractValidator<? super V>[] |
validators
The child validators.
|
PROPERTY_MANDATORY, PROPERTY_MAXIMUM, PROPERTY_MINIMUM
Constructor and Description |
---|
ComposedValidator(AbstractValidator<? super V>... validators)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
ComposedValidator<V> |
append(AbstractValidator<? super V>... additionalValidators) |
boolean |
contains(AbstractValidator<?> validator) |
boolean |
equals(Object obj) |
protected String |
getCode()
This is the default implementation to retrieve the
code of this
ValueValidator . |
<P> P |
getProperty(TypedProperty<P> property)
Gets the value of a property.
|
AbstractValidator<? super V> |
getValidator(int index)
Gets the
ValueValidator at the given index . |
int |
getValidatorCount() |
int |
hashCode() |
ValidationFailure |
validate(V value,
Object valueSource)
This method validates the given
value . |
createBundle, isDynamic, isMandatory, validate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
validate
public static final String CODE
getCode()
,
Constant Field Valuesprivate final AbstractValidator<? super V>[] validators
@SafeVarargs public ComposedValidator(AbstractValidator<? super V>... validators)
validators
- are the validators
to compose.protected String getCode()
AbstractValidator
code
of this
ValueValidator
. classname
of the actual
ValueValidator
implementation. This strategy is chosen for simplicity when implementing a new validator. To
ensure stable codes override this method and return a string constant. This shall at least be done when the name of
the class is changed.getCode
in class AbstractValidator<V>
code
.public ValidationFailure validate(V value, Object valueSource)
ValueValidator
value
.validate
in interface ValueValidator<V>
value
- is the value to validate.valueSource
- is the source
describing the origin of the given
value
. This may be the filename where the value was read from, an XPath where the value was located
in an XML document, the label of a widget of the UI containing the value, etc. This will help to find the
problem easier. The source needs to have a reasonable string-representation
as
this may be displayed to the end-user to locate the source of the failure. In most cases it is suitable to
directly pass a String
.ValidationFailure
or null
if the given value
is valid according to this
ValueValidator
.public int getValidatorCount()
getValidatorCount
in interface ComposedValueValidator<V>
validators
.getValidator(int)
,
Collection.size()
public AbstractValidator<? super V> getValidator(int index)
ValueValidator
at the given index
.getValidator
in interface ComposedValueValidator<V>
index
- is the index of the ValueValidator
to get.ValueValidator
.List.get(int)
public <P> P getProperty(TypedProperty<P> property)
AbstractValidator
getProperty
in class AbstractValidator<V>
P
- the generic type of the requested property.property
- the TypedProperty
.null
if undefined.public boolean contains(AbstractValidator<?> validator)
public ComposedValidator<V> append(AbstractValidator<? super V>... additionalValidators)
append
in class AbstractValidator<V>
additionalValidators
- the validators
to append.ComposedValidator
instance composing the current validator (this
) with the given
validator.public int hashCode()
hashCode
in class AbstractValidator<V>
public boolean equals(Object obj)
equals
in class AbstractValidator<V>
Copyright © 2001–2016 mmm-Team. All rights reserved.