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:

Changes for 1.2:

Since:
1.0
Version:
1.2
Author:
M.Reuvers

Method Summary
static AnnotationClassCache createCacheForClass(java.lang.Class clazz, JvConfiguration config)
          Creates a new AnnotationClassCache for given clazz.
static java.util.List<ValueModel> createValueModelForCache(AnnotationClassCache classCache, java.lang.Class clazz, java.lang.Object currentInstance, JvConfiguration config)
           
static ValueModel createValueModelForCacheSingleProperty(AnnotationClassCache classCache, java.lang.Class clazz, java.lang.Object currentInstance, java.lang.Object propertyValue, java.lang.String propertyName, JvConfiguration config)
           
static java.util.List<ValueModel> createValueModelForClassLevelCache(AnnotationClassCache classCache, java.lang.Class clazz, java.lang.Object currentInstance)
          Gathers available classlevel cache annotations for given clazz and returns them in a list.
static java.util.List<java.lang.String> getClassNamesIncludingParents(java.lang.Class clazz)
          Returns a list containing all classnames (including the clazz itself) up to the class that defines the @ValidateDefinition (so you get the child to parent hierarchy), if @ValidateDefinition is defined on clazz it returns a list with the clazz name only.
static ValidateDefinition getValidationDefinition(java.lang.Class clazz)
           
static ValidateDefinition getValidationDefinition(java.lang.Object object)
          Checks given object and returns its ValidateDefinition if found, null otherwise.
static boolean isRecursionAllowedForGroup(JvGroup jvGroup, java.lang.String currentGroup)
           
static boolean mustGroupBeApplied(JvGroup jvGroup, java.lang.String group)
           
static boolean mustStopValidation(java.lang.String currentGroup, StopValidation stopValidation)
          Returns true if validation must be aborted for field/method it is currently.
static java.util.List<ValidationMessage> validateAsJsfBean(ValidateDefinition definition, java.lang.Object currentInstance, java.lang.String currentValidationPath, JvConfigurationWrapper config)
          This method performs validation using a JSF bean.
static java.util.List<ValidationMessage> validateAsNormalBean(ValidateDefinition definition, java.lang.Object value, java.lang.String currentValidationPath, CacheSupport cacheSupport, JvConfigurationWrapper config)
          This method performs a validation for an ordinary java-bean.
static java.util.List<ValidationMessage> validateAsSpringBean(ValidateDefinition definition, java.lang.Object currentInstance, java.lang.String currentValidationPath, JvConfigurationWrapper config)
          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
 

Method Detail

getValidationDefinition

public static final 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 static final ValidateDefinition getValidationDefinition(java.lang.Class clazz)

getClassNamesIncludingParents

public static final java.util.List<java.lang.String> getClassNamesIncludingParents(java.lang.Class clazz)
Returns a list containing all classnames (including the clazz itself) up to the class that defines the @ValidateDefinition (so you get the child to parent hierarchy), if @ValidateDefinition is defined on clazz it returns a list with the clazz name only. If no @ValidateDefinition is specified at all returns an empty list.

Parameters:
clazz - The class to check
Returns:
List with classnames containing child-to-parent hierarchy (of which parent defines the @ValidateDefinition)

createCacheForClass

public static final AnnotationClassCache createCacheForClass(java.lang.Class clazz,
                                                             JvConfiguration config)
Creates a new AnnotationClassCache for given clazz. Returns a fresh cache instance or null if the given clazz does not have a @ValidateDefinition on it.

Parameters:
clazz - The clazz to create a cache for
config - The configuration
Returns:
AnnotationClassCache for clazz with @ValidateDefinition defined, null otherwise.

createValueModelForCache

public static final java.util.List<ValueModel> createValueModelForCache(AnnotationClassCache classCache,
                                                                        java.lang.Class clazz,
                                                                        java.lang.Object currentInstance,
                                                                        JvConfiguration config)

createValueModelForClassLevelCache

public static final java.util.List<ValueModel> createValueModelForClassLevelCache(AnnotationClassCache classCache,
                                                                                  java.lang.Class clazz,
                                                                                  java.lang.Object currentInstance)
Gathers available classlevel cache annotations for given clazz and returns them in a list.

Parameters:
classCache - The classCache to look into
clazz - The clazz it is about
Returns:
List with annotations found

createValueModelForCacheSingleProperty

public static final ValueModel createValueModelForCacheSingleProperty(AnnotationClassCache classCache,
                                                                      java.lang.Class clazz,
                                                                      java.lang.Object currentInstance,
                                                                      java.lang.Object propertyValue,
                                                                      java.lang.String propertyName,
                                                                      JvConfiguration config)

mustGroupBeApplied

public static final boolean mustGroupBeApplied(JvGroup jvGroup,
                                               java.lang.String group)

isRecursionAllowedForGroup

public static final boolean isRecursionAllowedForGroup(JvGroup jvGroup,
                                                       java.lang.String currentGroup)

mustStopValidation

public static final boolean mustStopValidation(java.lang.String currentGroup,
                                               StopValidation stopValidation)
Returns true if validation must be aborted for field/method it is currently.

Parameters:
currentGroup - The currentGroup that is under validation (specified by the user)
stopValidation - The annotation which may stop the validation for the method/field
Returns:
True if validation must stop, false otherwise.

validateAsNormalBean

public static final java.util.List<ValidationMessage> validateAsNormalBean(ValidateDefinition definition,
                                                                           java.lang.Object value,
                                                                           java.lang.String currentValidationPath,
                                                                           CacheSupport cacheSupport,
                                                                           JvConfigurationWrapper config)
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
config - Configuration wrapper
Returns:
List of validation messages (or empty list if no errors were found)

validateAsSpringBean

public static final java.util.List<ValidationMessage> validateAsSpringBean(ValidateDefinition definition,
                                                                           java.lang.Object currentInstance,
                                                                           java.lang.String currentValidationPath,
                                                                           JvConfigurationWrapper config)
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
config - Configuration wrapper
Returns:
List of validation messages (or empty list if no errors were found)

validateAsJsfBean

public static final java.util.List<ValidationMessage> validateAsJsfBean(ValidateDefinition definition,
                                                                        java.lang.Object currentInstance,
                                                                        java.lang.String currentValidationPath,
                                                                        JvConfigurationWrapper config)
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
config - Configuration wrapper
Returns:
List of validation messages (or empty list if no errors were found)