|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.site.MetaData<B,P>
public abstract class MetaData<B extends ConstrainedBean,P extends ConstrainedProperty>
This abstract base class can be conveniently used to added Constrained and ValidatedConstrained meta data to a POJO.
Besides implementing all the required interfaces for you, it also sets up the underlying data structures in a lazy fashion. This allows you to benefit from a rich API without the memory overhead when the meta data isn't used.
MetaDataMerged,
MetaDataBeanAware| Constructor Summary | |
|---|---|
MetaData()
|
|
| Method Summary | |
|---|---|
void |
activateMetaData()
This method is called at least once and maximum once when any meta-data introspection logic is executed. |
List<PropertyValidationRule> |
addConstrainedPropertyRules(P constrainedProperty)
Adds the validation rules that are related to a particular ConstrainedProperty. |
void |
addConstraint(B constrainedBean)
Add a new constrained bean. |
void |
addConstraint(P constrainedProperty)
Add a new constrained property. |
ValidationGroup<P> |
addGroup(String name)
Adds a new validation group. |
void |
addRule(ValidationRule rule)
Adds a new validation rule. |
void |
addValidationError(ValidationError error)
Add a new validation error explicitly to the collection of already existing errors. |
Object |
clone()
|
int |
countValidationErrors()
Counts the number of stored ValidationErrors. |
void |
focusGroup(String name)
Focuses on one particular validation group, showing only the ValidationErrors that were generated by its
ValidationRules. |
List<PropertyValidationRule> |
generateConstrainedPropertyRules(P constrainedProperty)
Generates the validation rules that are related to a particular ConstrainedProperty. |
B |
getConstrainedBean()
Retrieves the constrained bean that has been set for this Constrained instance. |
Collection<P> |
getConstrainedProperties()
Returns a collection with all the constrained properties that have been registered. |
P |
getConstrainedProperty(String propertyName)
Retrieve a registered ConstrainedProperty according to
its name. |
ValidationGroup<P> |
getGroup(String name)
Retrieve a particular validation group. |
Collection<ValidationGroup<P>> |
getGroups()
Retrieves all validation groups. |
Collection<String> |
getLoadingErrors(String propertyName)
Returns the collection of error messages that occurred during the loading of the content of a certain property. |
List<ValidationRule> |
getRules()
Retrieves that validation rules that have been registered. |
List<String> |
getValidatedSubjects()
Returns the list of subjects that this object is able to validate internally through the validate() method. |
Set<ValidationError> |
getValidationErrors()
Returns a set with all the stored ValidationErrors. |
boolean |
hasPropertyConstraint(String name)
Indicates whether this constrained bean contains a particular constraint on at least one of its properties. |
boolean |
isSubjectValid(String subject)
Checks if a subject is valid. |
void |
limitSubjectErrors(String subject)
Limits the number of errors for a particular subject so that maximum one ValidationError can be stored for it. |
void |
makeErrorValid(String identifier,
String subject)
Makes errors for a particular subject and identifier valid. |
void |
makeSubjectValid(String subject)
Makes a subject valid. |
void |
provideValidatedBean(Validated bean)
Provide the bean instance that will be validated. |
void |
replaceValidationErrors(Set<ValidationError> errors)
Replaces the stored ValidationErrors with a new set of
errors. |
void |
resetGroup(String name)
Removed all the ValidationErrors of a particular
validation group. |
void |
resetValidation()
Resets the validation by removing all validation errors that are currently present. |
Validated |
retrieveValidatedBean()
Retrieves the bean instance that will be validated. |
void |
setMetaDataBean(Object bean)
This method will be called by RIFE when a new instance of the meta data class has been created. |
void |
unlimitSubjectErrors(String subject)
Unlimits the number of errors for a particular subject so that any number of ValidationErrors can be stored for it. |
boolean |
validate()
Validates the internal subjects. |
boolean |
validate(ValidationContext context)
Validates the internal subjects and also validates the bean within the provided ValidationContext |
boolean |
validateGroup(String name)
Validate the ValidationRules of a particular validation
group. |
boolean |
validateGroup(String name,
ValidationContext context)
Validate the ValidationRules of a particular validation
group and also validates the entire bean within the provided
ValidationContext |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MetaData()
| Method Detail |
|---|
public void activateMetaData()
You need to implement this method since it will be called after the underlying validation context has been initialized. Incidentally, by doing all your meta data setup here, you don't enforce a performance penalty at each object construction like when you do this in the default constructor.
public final void setMetaDataBean(Object bean)
MetaDataBeanAwareThis method will be called by RIFE when a new instance of the meta data class has been created.
setMetaDataBean in interface MetaDataBeanAwarebean - the bean instance that this particular meta data instance
has been associated withpublic void provideValidatedBean(Validated bean)
ValidatedBy default 'this' will be used.
provideValidatedBean in interface Validatedbean - the bean instance that will be validatedpublic final Validated retrieveValidatedBean()
Validated
retrieveValidatedBean in interface Validatedpublic void addConstraint(B constrainedBean)
ConstrainedWhen several constrained beans are added, they are merged at constraint-level. This means for instance that all previous unique constraints will be replaced by those of the new constrained bean, they will not be combined.
addConstraint in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>constrainedBean - the ConstrainedBean instance
that has to be addedConstrainedBeanpublic void addConstraint(P constrainedProperty)
ConstrainedWhen several of the same constrained properties are added, they are merged at constraint-level. This means for instance that a previous inList constraint will be replaced by the one of the new constrained bean, they will not be combined.
addConstraint in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>constrainedProperty - the ConstrainedProperty
instance that has to be addedConstrainedPropertypublic B getConstrainedBean()
ConstrainedConstrained instance.
getConstrainedBean in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>ConstrainedBean; or
null if no ConstrainedBean is
available.
ConstrainedPropertypublic Collection<P> getConstrainedProperties()
Constrained
getConstrainedProperties in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>Collection with all the
ConstrainedProperty objects that are registered. If no
constrained properties are available, an empty collection will be
returned, not null.ConstrainedPropertypublic boolean hasPropertyConstraint(String name)
Constrained
hasPropertyConstraint in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>true if this constraint is present on at least one
of the properties; or
false otherwise
ConstrainedPropertypublic P getConstrainedProperty(String propertyName)
ConstrainedConstrainedProperty according to
its name.
getConstrainedProperty in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>propertyName - the name of the
ConstrainedProperty that has to be retrieved
ConstrainedProperty; or
null if no such ConstrainedProperty is
available.
ConstrainedPropertypublic boolean validate()
ValidatedThis method is not suppossed to reset the validation errors or to start the validation from scratch, but it's intended to add additional errors to an existing collection.
validate in interface Validatedtrue if no validation errors are present after the
validation; or
false if validation errors are available.
Validated.validate(ValidationContext),
Validated.resetValidation()public boolean validate(ValidationContext context)
ValidatedValidationContext
This method is not suppossed to reset the validation errors or to start the validation from scratch, but it's intended to add additional errors to an existing collection.
validate in interface Validatedcontext - the ValidationContext in which this bean
instance will be additionally validated
true if no validation errors are present after the
validation; or
false if validation errors are available.
Validated.validate(),
Validated.resetValidation()public void resetValidation()
ValidatedResets the validation by removing all validation errors that are currently present.
This method is typically used to start a new validation from scratch or to re-validate until all errors have been solved.
resetValidation in interface ValidatedValidated.validate()public void addValidationError(ValidationError error)
ValidatedNote that this method should respect subjects with a limited error amount and only store the first error for these subjects.
addValidationError in interface Validatederror - the ValidationError to addValidated.limitSubjectErrors(String),
Validated.unlimitSubjectErrors(String)public Set<ValidationError> getValidationErrors()
ValidatedValidationErrors.
getValidationErrors in interface ValidatedSet instance with all the stored
ValidationErrors. Note that when no errors are available
an empty set is returned, not null.public int countValidationErrors()
ValidatedValidationErrors.
countValidationErrors in interface ValidatedValidationErrors.public void replaceValidationErrors(Set<ValidationError> errors)
ValidatedValidationErrors with a new set of
errors.
replaceValidationErrors in interface Validatederrors - the Set instance that contains all the
ValidationErrors that have to be stored.public void limitSubjectErrors(String subject)
ValidatedValidationError can be stored for it.
limitSubjectErrors in interface Validatedsubject - the name of the subject that has to be limited.public void unlimitSubjectErrors(String subject)
ValidatedValidationErrors can be stored for it.
unlimitSubjectErrors in interface Validatedsubject - the name of the subject that has to be unlimited.public List<String> getValidatedSubjects()
Validatedvalidate() method.
getValidatedSubjects in interface Validatedpublic boolean isSubjectValid(String subject)
ValidatedThis is determined by verifying if there are
ValidationErrors present for it. This method will thus not
execute a validation action.
isSubjectValid in interface Validatedsubject - the name of the subject that has to be checked.
true when no errors could be found for the
subject; or
false when errors are present for the subject.
Validated.validate()
public void makeErrorValid(String identifier,
String subject)
ValidatedThis is done by removing all ValidationErrors that are
stored with this identifier and subject.
makeErrorValid in interface Validatedidentifier - the name of the error identifier that has to be madesubject - the name of the subject that has to be made valid.
valid.public void makeSubjectValid(String subject)
ValidatedThis is done by removing all ValidationErrors that are
stored for it.
makeSubjectValid in interface Validatedsubject - the name of the subject that has to be made valid.public ValidationGroup<P> addGroup(String name)
ValidatedConstrained
addGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that needs to be created
and added
ValidationGrouppublic void focusGroup(String name)
ValidatedConstrainedValidationErrors that were generated by its
ValidationRules.
focusGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be focusedpublic void resetGroup(String name)
ValidatedConstrainedValidationErrors of a particular
validation group.
resetGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be focusedpublic void addRule(ValidationRule rule)
ValidatedAdds a new validation rule.
The collection of rules is what is supposed to perform the validation, though any other additional method could be used. At least those rules that have been registered will be evaluated.
addRule in interface Validatedrule - the rule that will be addedValidated.validate(),
Validated.getRules()public List<PropertyValidationRule> addConstrainedPropertyRules(P constrainedProperty)
ValidatedConstrainedConstrainedProperty.
If the rules of this property name have already been added before
through another ConstrainedProperty instance, its existing
ValidationRules will be erased and the previous
constraints will be merged into the new
ConstrainedProperty before adding its validation rules.
addConstrainedPropertyRules in interface ValidatedConstrained<P extends ConstrainedProperty>constrainedProperty - the ConstrainedProperty that will be
inspected
ValidationRulespublic List<PropertyValidationRule> generateConstrainedPropertyRules(P constrainedProperty)
ValidatedConstrainedConstrainedProperty.
generateConstrainedPropertyRules in interface ValidatedConstrained<P extends ConstrainedProperty>constrainedProperty - the ConstrainedProperty that will be
inspected
ValidationRulespublic List<ValidationRule> getRules()
Validated
getRules in interface ValidatedValidated.validate(),
Validated.addRule(com.uwyn.rife.site.ValidationRule)public Collection<ValidationGroup<P>> getGroups()
ValidatedConstrained
getGroups in interface ValidatedConstrained<P extends ConstrainedProperty>public ValidationGroup<P> getGroup(String name)
ValidatedConstrained
getGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be retrieved
ValidationGroup; or
null if no such validation group exists
public boolean validateGroup(String name)
ValidatedConstrainedValidationRules of a particular validation
group.
validateGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be retrieved
true if no validation errors were generated; or
false otherwise
public boolean validateGroup(String name,
ValidationContext context)
ValidatedConstrainedValidationRules of a particular validation
group and also validates the entire bean within the provided
ValidationContext
validateGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation groupcontext - the ValidationContext in which this bean
instance will be additionally validated
true if no validation errors were generated; or
false otherwise
public Collection<String> getLoadingErrors(String propertyName)
ValidatedConstrained
getLoadingErrors in interface ValidatedConstrained<P extends ConstrainedProperty>propertyName - the name of the property whose loading errors
should be obtained
the requested collection of error messages
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||