org.javalid.core
Class AnnotationStorage

java.lang.Object
  extended by org.javalid.core.AnnotationStorage
All Implemented Interfaces:
java.io.Serializable

public class AnnotationStorage
extends java.lang.Object
implements java.io.Serializable

Class for putting everything together, related to a method / field for validation.

Since:
1.0
Version:
1.0
Author:
M.Reuvers
See Also:
Serialized Form

Constructor Summary
AnnotationStorage(java.lang.reflect.Method method, java.lang.reflect.Field field, java.lang.String groupName, java.lang.String path, java.util.List<java.lang.annotation.Annotation> annotations, java.util.List<JvGroup> listGroups)
          Construct this object.
 
Method Summary
 java.util.List<java.lang.annotation.Annotation> getAnnotations()
           
 java.lang.reflect.Field getField()
           
 java.lang.String getGroupName()
           
 java.lang.reflect.Method getMethod()
           
 NotEmpty getNotEmptyAnnotation()
          Convenience method to directly get the NotEmpty annotation on this method.
 NotNull getNotNullAnnotation()
          Convenience method to directly get the NotNull annotation on this method.
 java.lang.String getPath()
           
protected  void init()
          Initializes everything, called from constructor.
 boolean isAnnotationValidated(java.lang.annotation.Annotation annotation)
          Returns true if given annotation-class has already been validated on the method's value (so there's no need to validate them twice).
 boolean isRecursionAllowed(java.lang.String group)
          Returns true if recursion for this group is allowed, false if it is not.
 void setAnnotationValidated(java.lang.annotation.Annotation annotation, boolean validated, boolean validatedValid)
          Change the validation for a fully qualified annotation class name
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnnotationStorage

public AnnotationStorage(java.lang.reflect.Method method,
                         java.lang.reflect.Field field,
                         java.lang.String groupName,
                         java.lang.String path,
                         java.util.List<java.lang.annotation.Annotation> annotations,
                         java.util.List<JvGroup> listGroups)
Construct this object.

Parameters:
method - The method to apply validation to (can be null, but then field must be set)
field - The field to apply validation to (can be null, but then method must be set)
path - Full path (with prefix if there) when validating, the methodName of this method must be added. e.g. person.value (where person is the current path and .value the current method)
groupName - The groupName currently under validation
annotations - The annotations that were found on either method or field with the same group name as the groups. Annotations with no groupnames will always be included as they apply to all groups then.
listGroups - The group annotations found on the methods, the first entry always contains the method that was being validated, use that one to determine if recursion is allowed or not.
Method Detail

init

protected void init()
Initializes everything, called from constructor.


getGroupName

public java.lang.String getGroupName()

getPath

public java.lang.String getPath()

getMethod

public java.lang.reflect.Method getMethod()

getAnnotations

public java.util.List<java.lang.annotation.Annotation> getAnnotations()

getNotNullAnnotation

public NotNull getNotNullAnnotation()
Convenience method to directly get the NotNull annotation on this method. Returns null if not declared for this method.

Returns:
NotNull annotation, if not declared for this method returns null.

getNotEmptyAnnotation

public NotEmpty getNotEmptyAnnotation()
Convenience method to directly get the NotEmpty annotation on this method. Returns null if not declared for this method.

Returns:
NotEmpty annotation, if not declared for this method returns null.

isAnnotationValidated

public boolean isAnnotationValidated(java.lang.annotation.Annotation annotation)
Returns true if given annotation-class has already been validated on the method's value (so there's no need to validate them twice). False otherwise, this is relevant if inheritance is used. Raises an JvException if requested annotation is not registered in this class.

Parameters:
annotation - The validation annotation
Returns:
True if validated for this method already, false otherwise.

setAnnotationValidated

public void setAnnotationValidated(java.lang.annotation.Annotation annotation,
                                   boolean validated,
                                   boolean validatedValid)
Change the validation for a fully qualified annotation class name

Parameters:
annotation - The validation annotation
validated - Set to true if the annotation is validated, false otherwise.
validatedValid - Set to true if no error was found, false otherwise. Note that if parameter validated is false, this parameter is ignored.

isRecursionAllowed

public boolean isRecursionAllowed(java.lang.String group)
Returns true if recursion for this group is allowed, false if it is not. Checks the first JvGroup in the list of groups.

Parameters:
group - The group to check
Returns:
True if recursion is allowed, false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getField

public java.lang.reflect.Field getField()