org.javalid.core.support
Class AnnotationSupport

java.lang.Object
  extended by org.javalid.core.support.AnnotationSupport

public class AnnotationSupport
extends java.lang.Object

Supportive class for reading core annotations and performing related actions.

Changes for 1.1:

Since:
1.0
Version:
1.1
Author:
M.Reuvers

Constructor Summary
AnnotationSupport(JvConfiguration config)
           
 
Method Summary
 java.util.List<AnnotationStorage> getAnnotationStorageForFields(java.lang.Object currentObject, java.lang.String group, java.lang.String currentPath)
           
 java.util.List<AnnotationStorage> getAnnotationStorageForMethods(java.lang.Object currentObject, java.lang.String group, java.lang.String currentPath)
          Returns a list containing AnnotationStorage objects.
 AnnotationStorage getFieldInfoPropertyDeprecated(java.lang.Object object, java.lang.reflect.Field field, java.lang.String group, java.lang.String currentPath, JvConfigurationWrapper jvConfigWrapper)
          Deprecated. Temporaly introduced to allow field property validation to work, but WILL be removed in 1.2
 AnnotationStorage getMethodInfo(java.lang.Object object, java.lang.reflect.Method method, java.lang.String group, java.lang.String currentPath, JvConfigurationWrapper jvConfigWrapper)
          Returns AnnotationStorage instance if the method must be validated either by itself or in one of its parent classes (must have JvGroup), in all other cases returns null (so skip this method).
 ValidateDefinition getValidationDefinition(java.lang.Class clazz)
           
 ValidateDefinition getValidationDefinition(java.lang.Object object)
          Checks given object and returns its ValidateDefinition if found, null otherwise.
 java.util.List<ValidationMessage> validateAsJsfBean(ValidateDefinition definition, java.lang.Object currentInstance, java.lang.String currentValidationPath)
          This method performs validation using a JSF bean.
 java.util.List<ValidationMessage> validateAsNormalBean(ValidateDefinition definition, java.lang.Object value, java.lang.String currentValidationPath, CacheSupport cacheSupport)
          This method performs a validation for an ordinary java-bean.
 java.util.List<ValidationMessage> validateAsSpringBean(ValidateDefinition definition, java.lang.Object currentInstance, java.lang.String currentValidationPath)
          This method performs validation using a Spring bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationSupport

public AnnotationSupport(JvConfiguration config)
Method Detail

getValidationDefinition

public ValidateDefinition getValidationDefinition(java.lang.Object object)
Checks given object and returns its ValidateDefinition if found, null otherwise.

Parameters:
object - The object to check
Returns:
ValidateDefinition if found, null otherwise.

getValidationDefinition

public ValidateDefinition getValidationDefinition(java.lang.Class clazz)

getAnnotationStorageForMethods

public java.util.List<AnnotationStorage> getAnnotationStorageForMethods(java.lang.Object currentObject,
                                                                        java.lang.String group,
                                                                        java.lang.String currentPath)
Returns a list containing AnnotationStorage objects. Each storage represents all validations for one method.

Parameters:
currentObject - The current object to check the methods on
group - The current group
currentPath - The current validation path
Returns:
List with AnnotationStorage instances

getAnnotationStorageForFields

public java.util.List<AnnotationStorage> getAnnotationStorageForFields(java.lang.Object currentObject,
                                                                       java.lang.String group,
                                                                       java.lang.String currentPath)

getMethodInfo

public AnnotationStorage getMethodInfo(java.lang.Object object,
                                       java.lang.reflect.Method method,
                                       java.lang.String group,
                                       java.lang.String currentPath,
                                       JvConfigurationWrapper jvConfigWrapper)
Returns AnnotationStorage instance if the method must be validated either by itself or in one of its parent classes (must have JvGroup), in all other cases returns null (so skip this method).

Careful, if this method contains a super.method() with JvGroup that has exposeInSubClass set to true this method *DOES* return that JvGroup too, even if the JvGroup is not specified directly on this method. This way it's possible to define more rules in subclasses in addition to super class rules. The order in which they are returned is undefined.

Parameters:
object - The object this method is from
method - The method to check
group - The group to check
currentPath - The current path of this object
jvConfigWrapper - Configuration (needed for proxy checking e.g)
Returns:
AnnotationStorage if at least JvGroup annotation was found or null

getFieldInfoPropertyDeprecated

public AnnotationStorage getFieldInfoPropertyDeprecated(java.lang.Object object,
                                                        java.lang.reflect.Field field,
                                                        java.lang.String group,
                                                        java.lang.String currentPath,
                                                        JvConfigurationWrapper jvConfigWrapper)
Deprecated. Temporaly introduced to allow field property validation to work, but WILL be removed in 1.2

ONLY for field property validation, do not use for anything else! Will be removed during refactoring for 1.2 version!!!! -- Currently broken: Expose in subclass=false is NOT checked, it will always be found now.

Parameters:
object -
field -
group -
currentPath -
jvConfigWrapper -
Returns:
AnnotationStorage
Since:
1.1

validateAsNormalBean

public java.util.List<ValidationMessage> validateAsNormalBean(ValidateDefinition definition,
                                                              java.lang.Object value,
                                                              java.lang.String currentValidationPath,
                                                              CacheSupport cacheSupport)
This method performs a validation for an ordinary java-bean. It expects the beanLookup to be defined and valid. Using that information to perform a validation. Raises JvException if something goes wrong.

Parameters:
definition - The definition the validating bean is originally from (the definiton of the class currently being validated)
value - The actual instance needing validation
currentValidationPath - The current validation path for this object
cacheSupport - The cachesupport to use when caching beans is allowed
Returns:
List of validation messages (or empty list if no errors were found)

validateAsSpringBean

public java.util.List<ValidationMessage> validateAsSpringBean(ValidateDefinition definition,
                                                              java.lang.Object currentInstance,
                                                              java.lang.String currentValidationPath)
This method performs validation using a Spring bean. It expects the beanLookup to be defined and valid. Using that information to perform a validation. Raises JvException if something goes wrong.

Parameters:
definition - The definition the validating bean is originally from (the definiton of the class currently being validated)
currentInstance - The actual instance needing validation
Returns:
List of validation messages (or empty list if no errors were found)

validateAsJsfBean

public java.util.List<ValidationMessage> validateAsJsfBean(ValidateDefinition definition,
                                                           java.lang.Object currentInstance,
                                                           java.lang.String currentValidationPath)
This method performs validation using a JSF bean. It expects the beanLookup to be defined and valid. Using that information to perform a validation. Raises JvException if something goes wrong.

Parameters:
definition - The definition the validating bean is originally from (the definiton of the class currently being validated)
currentInstance - The actual instance needing validation
Returns:
List of validation messages (or empty list if no errors were found)