V
- is the generic type of the value to validate
.public abstract class AbstractValidator<V> extends Object implements ValueValidator<V>
ValueValidator
implementations should extend.Modifier and Type | Field and Description |
---|---|
static TypedProperty<Boolean> |
PROPERTY_MANDATORY
Property for mandatory flag . |
static TypedProperty<Comparable> |
PROPERTY_MAXIMUM
Property for maximum value (null if unbounded). |
static TypedProperty<Comparable> |
PROPERTY_MINIMUM
Property for minimum value (null if unbounded). |
Constructor and Description |
---|
AbstractValidator()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
AbstractValidator<V> |
append(AbstractValidator<? super V>... validators) |
boolean |
contains(AbstractValidator<?> validator) |
protected <BUNDLE extends NlsBundle> |
createBundle(Class<BUNDLE> bundleInterface)
This is a convenience method delegating to
NlsBundleFactory.createBundle(Class) . |
abstract 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.
|
abstract int |
hashCode() |
boolean |
isDynamic()
This method determines if this
ValueValidator is dynamic. |
boolean |
isMandatory() |
ValidationFailure |
validate(V value)
This method validates the given
value . |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
validate
public static final TypedProperty<Boolean> PROPERTY_MANDATORY
Property
for mandatory flag
.public static final TypedProperty<Comparable> PROPERTY_MINIMUM
Property
for minimum value (null
if unbounded).public static final TypedProperty<Comparable> PROPERTY_MAXIMUM
Property
for maximum value (null
if unbounded).protected String getCode()
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.code
.public final ValidationFailure validate(V value)
ValueValidator
value
.validate
in interface ValueValidator<V>
value
- is the value to validate.ValidationFailure
or null
if the given value
is valid according to this
ValueValidator
.public boolean isDynamic()
ValueValidator
is dynamic. Here dynamic means that the validation
of the same input may not always return the same validation result (e.g. it holds references to instances that have
dynamic impact on the validation).true
if this ValueValidator
is dynamic, false
otherwise.public final boolean isMandatory()
true
if this is a validator for mandatory fields (that will not accept null
or empty
values), false
otherwise.protected <BUNDLE extends NlsBundle> BUNDLE createBundle(Class<BUNDLE> bundleInterface)
NlsBundleFactory.createBundle(Class)
.public <P> P getProperty(TypedProperty<P> property)
P
- the generic type of the requested property.property
- the TypedProperty
.null
if undefined.public boolean contains(AbstractValidator<?> validator)
public AbstractValidator<V> append(AbstractValidator<? super V>... validators)
validators
- the validators
to append.ComposedValidator
instance composing the current validator (this
) with the given
validator.Copyright © 2001–2016 mmm-Team. All rights reserved.