public class DefaultValidationMetadataProvider extends java.lang.Object implements ValidationMetadataProvider
ValidationMetadataProvider
that scans classes and their superclasses
for properties annotated with Validate
and/or ValidateNestedProperties
and
exposes the validation metadata specified by those annotations. When searching for annotations,
this implementation looks first at the property's read method (getter), then its write method
(setter), and finally at the field itself.Constructor and Description |
---|
DefaultValidationMetadataProvider() |
Modifier and Type | Method and Description |
---|---|
Configuration |
getConfiguration()
Get the
Configuration object that was passed into init(Configuration) . |
java.util.Map<java.lang.String,ValidationMetadata> |
getValidationMetadata(java.lang.Class<?> beanType)
Get a map of property names to
ValidationMetadata for the given ActionBean
class. |
ValidationMetadata |
getValidationMetadata(java.lang.Class<?> beanType,
ParameterName field)
Get the validation metadata associated with the named
property of the given
ActionBean class. |
void |
init(Configuration configuration)
Currently does nothing except store a reference to
configuration . |
protected java.util.Map<java.lang.String,ValidationMetadata> |
loadForClass(java.lang.Class<?> beanType)
Get validation information for all the properties and nested properties of the given class.
|
public void init(Configuration configuration) throws java.lang.Exception
configuration
.init
in interface ConfigurableComponent
configuration
- the Configuration object being used by Stripesjava.lang.Exception
- should be thrown if the component cannot be configured well enough to use.public Configuration getConfiguration()
Configuration
object that was passed into init(Configuration)
.public java.util.Map<java.lang.String,ValidationMetadata> getValidationMetadata(java.lang.Class<?> beanType)
ValidationMetadataProvider
ValidationMetadata
for the given ActionBean
class.getValidationMetadata
in interface ValidationMetadataProvider
beanType
- any classValidationMetadata
. If no validation information
is present for the given class, then an empty map will be returned.public ValidationMetadata getValidationMetadata(java.lang.Class<?> beanType, ParameterName field)
ValidationMetadataProvider
property
of the given
ActionBean
class.getValidationMetadata
in interface ValidationMetadataProvider
beanType
- any classfield
- a (possibly nested) property of beanType
ValidationMetadata
object, if there is one associated with the property. If
the property is not to be validated, then null.protected java.util.Map<java.lang.String,ValidationMetadata> loadForClass(java.lang.Class<?> beanType)
Validate
and/or ValidateNestedProperties
annotations may be applied to
the property's read method, write method, or field declaration. If a property has a
ValidateNestedProperties
annotation, then the nested properties named in its
Validate
annotations will be included as well.beanType
- a classValidationMetadata
for the
property.StripesRuntimeException
- if conflicts are found in the validation annotations? Copyright 2005-2006, Stripes Development Team.